library(rmarkdown) # Documentation generation
library(officer) # Manipulating Microsoft Word documents
library(flextable) # Creating formatted tables in Microsoft Word documents
library(tableHTML) # Creating tables in HTML format
library(gtsummary) # Creating summary tables
library(here) # Dealing with file path
# ---- dealing with data
library(dplyr) # Data manipulation and transformation
library(tidyr) # Data tidying
library(DataExplorer) # Exploratory data analysis
library(compareGroups) # Comparing groups
library(psych) # Psychological statistics and data manipulation
library(Hmisc) # Miscellaneous functions for data analysis
library(purrr)
# ---- Survival analysis
library(poptrend) # Calculating p-trend in survival analysis
library(survival) # Survival analysis
library(survivalAnalysis) # Survival analysis functions
library(survminer) # Drawing survival curves
library(adjustedCurves) # Plotting adjusted survival curves
library(pammtools) # Plotting adjusted survival curves
library(survIDINRI) # Make reclassification and discrimination
library(glmnet) # Regularized regression models
library(olsrr) # Variable selection at its best !
library(StepReg) # Variable selection at its best !
# ---- Graphics
library(ggplot2) # Data visualization
library(mctest) # Multiple hypothesis testing --> assess colinearity between continuous variable
library(corrplot) # Visualizing correlation matrices
library(fmsb) # Creating radar plots
library(concreg) # Plotting adjusted survival curves
library(ggpubr) # Associating the risk table when plotting
# My packages
# Function to source all R files in a specified directory
source_all <- function(directory_path) {
# Obtain a list of R script files in the directory
r_files <- list.files(directory_path, pattern = "\\.R$", full.names = TRUE)
# Source each file
for (file in r_files) {
source(file)
}
}
# Usage example:
# Assuming your scripts are stored in the 'Functions' directory within your project
source_all(here("Functions_R"))Using the data.management_ICM_Tradi_V4 results directly saved in RData. * df_all : 6,082 patients * df_LGE : 3,591 patients
Descr_table = createTable(compareGroups(
CMR_LGE_midwall_presence ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
CMR_LVEF + CMR_LVEDV +
CMR_LVESV + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_presence_ischemic_and_midwall +
CMR_LGE_ischemic_presence +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_extent_categ +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_midwall_presence +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_extent_categ +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical +
outcome_revascularisation_90days,
data= df_all,
method = 1, conf.level = 0.95),
hide.no = "No",
show.all=T, show.p.overall = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| [ALL] | A_No_midwall_LGE | B_Presence_of_midwall_LGE | p.overall | |
|---|---|---|---|---|
| N=6082 | N=5380 | N=702 | ||
| demo_age | 64.5 (11.8) | 64.4 (11.8) | 65.8 (11.6) | 0.002 |
| demo_gender | 4419 (72.7%) | 3894 (72.4%) | 525 (74.8%) | 0.193 |
| demo_BMI | 27.7 (5.33) | 27.6 (5.31) | 28.3 (5.43) | 0.005 |
| CV_risk_diabete | 2309 (38.0%) | 1985 (36.9%) | 324 (46.2%) | <0.001 |
| CV_risk_HTA | 3144 (51.7%) | 2665 (49.5%) | 479 (68.2%) | <0.001 |
| CV_risk_obesity | 1687 (27.7%) | 1459 (27.1%) | 228 (32.5%) | 0.003 |
| CV_risk_dyslipidemia | 3005 (49.4%) | 2619 (48.7%) | 386 (55.0%) | 0.002 |
| CV_risk_Smoking | 1285 (21.1%) | 1144 (21.3%) | 141 (20.1%) | 0.503 |
| history_med_MI | 2354 (38.7%) | 2082 (38.7%) | 272 (38.7%) | 1.000 |
| history_coronary_procedure | 5394 (88.7%) | 4775 (88.8%) | 619 (88.2%) | 0.696 |
| history_interv_PCI | 380 (6.25%) | 336 (6.25%) | 44 (6.27%) | 1.000 |
| history_interv_CABG | 5085 (83.6%) | 4501 (83.7%) | 584 (83.2%) | 0.793 |
| med_periph_atheroma | 344 (5.66%) | 298 (5.54%) | 46 (6.55%) | 0.314 |
| history_stroke | 186 (3.06%) | 165 (3.07%) | 21 (2.99%) | 1.000 |
| med_pacemaker | 41 (0.67%) | 28 (0.52%) | 13 (1.85%) | <0.001 |
| med_CKD | 121 (1.99%) | 93 (1.73%) | 28 (3.99%) | <0.001 |
| history_hospit_HF | 368 (6.05%) | 332 (6.17%) | 36 (5.13%) | 0.315 |
| history_AFib | 453 (7.45%) | 377 (7.01%) | 76 (10.8%) | <0.001 |
| clini_NYHA | 753 (12.4%) | 681 (12.7%) | 72 (10.3%) | 0.079 |
| clini_cardiac_rythm | 426 (7.00%) | 360 (6.69%) | 66 (9.40%) | 0.010 |
| CMR_LVEF | 43.7 (5.70) | 43.8 (5.69) | 43.3 (5.78) | 0.034 |
| CMR_LVEDV | 103 (21.5) | 103 (21.5) | 104 (21.6) | 0.188 |
| CMR_LVESV | 58.6 (17.8) | 58.5 (17.8) | 59.6 (17.6) | 0.102 |
| CMR_LV_mass | 91.0 (19.5) | 90.7 (19.7) | 93.5 (17.8) | <0.001 |
| CMR_RV_dysfunction | 218 (3.58%) | 188 (3.49%) | 30 (4.27%) | 0.349 |
| CMR_LGE_presence_ischemic_and_midwall | 354 (5.82%) | 0 (0.00%) | 354 (50.4%) | 0.000 |
| CMR_LGE_ischemic_presence: | <0.001 | |||
| No_ischemic_LGE | 2491 (41.0%) | 2143 (39.8%) | 348 (49.6%) | |
| Presence_of_ischemic_LGE | 3591 (59.0%) | 3237 (60.2%) | 354 (50.4%) | |
| CMR_LGE_ischemic_extent_count | 1.83 (1.96) | 1.83 (1.91) | 1.83 (2.26) | 0.998 |
| CMR_LGE_ischemic_extent_categ: | <0.001 | |||
| A_No_ischemic_LGE | 2491 (41.0%) | 2143 (39.8%) | 348 (49.6%) | |
| B_1_2_segments | 1392 (22.9%) | 1282 (23.8%) | 110 (15.7%) | |
| C_3_5_segments | 1953 (32.1%) | 1774 (33.0%) | 179 (25.5%) | |
| D_more6_segments | 246 (4.04%) | 181 (3.36%) | 65 (9.26%) | |
| CMR_LGE_ischemic_transmurality: | <0.001 | |||
| A_No_ischemic_LGE | 2491 (41.0%) | 2143 (39.8%) | 348 (49.6%) | |
| B_Subendocardial<50% | 1698 (27.9%) | 1572 (29.2%) | 126 (17.9%) | |
| C_Subendocardial≥50% | 1549 (25.5%) | 1392 (25.9%) | 157 (22.4%) | |
| D_Transmural | 344 (5.66%) | 273 (5.07%) | 71 (10.1%) | |
| CMR_LGE_ischemic_location_4: | <0.001 | |||
| A_No_ischemic_LGE | 2491 (41.0%) | 2143 (39.8%) | 348 (49.6%) | |
| B_Neither_anterior_nor_septal | 2662 (43.8%) | 2445 (45.4%) | 217 (30.9%) | |
| C_Anterior_without_septal | 422 (6.94%) | 379 (7.04%) | 43 (6.13%) | |
| D_Septal | 507 (8.34%) | 413 (7.68%) | 94 (13.4%) | |
| CMR_LGE_midwall_presence: | 0.000 | |||
| A_No_midwall_LGE | 5380 (88.5%) | 5380 (100%) | 0 (0.00%) | |
| B_Presence_of_midwall_LGE | 702 (11.5%) | 0 (0.00%) | 702 (100%) | |
| CMR_LGE_midwall_extent_count | 0.13 (0.39) | 0.00 (0.00) | 1.14 (0.37) | 0.000 |
| CMR_LGE_midwall_extent_categ: | 0.000 | |||
| None | 5380 (88.5%) | 5380 (100%) | 0 (0.00%) | |
| Low_=1 | 610 (10.0%) | 0 (0.00%) | 610 (86.9%) | |
| High_>1 | 92 (1.51%) | 0 (0.00%) | 92 (13.1%) | |
| CMR_LGE_midwall_location_3: | 0.000 | |||
| No_midwall_LGE | 5380 (88.5%) | 5380 (100%) | 0 (0.00%) | |
| Midwall_LGE_not_at_risk | 471 (7.74%) | 0 (0.00%) | 471 (67.1%) | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 231 (3.80%) | 0 (0.00%) | 231 (32.9%) | |
| CMR_LGE_midwall_location_4: | 0.000 | |||
| No_midwall_LGE | 5380 (88.5%) | 5380 (100%) | 0 (0.00%) | |
| Midwall_LGE_not_at_risk | 471 (7.74%) | 0 (0.00%) | 471 (67.1%) | |
| Lateral_midwall_LGE | 118 (1.94%) | 0 (0.00%) | 118 (16.8%) | |
| Septal_Midwall_LGE | 113 (1.86%) | 0 (0.00%) | 113 (16.1%) | |
| CMR_LGE_midwall_anterior | 140 (2.30%) | 0 (0.00%) | 140 (19.9%) | <0.001 |
| CMR_LGE_midwall_septal | 113 (1.86%) | 0 (0.00%) | 113 (16.1%) | <0.001 |
| CMR_LGE_midwall_inferior | 212 (3.49%) | 0 (0.00%) | 212 (30.2%) | 0.000 |
| CMR_LGE_midwall_lateral | 124 (2.04%) | 0 (0.00%) | 124 (17.7%) | <0.001 |
| CMR_LGE_midwall_apical | 146 (2.40%) | 0 (0.00%) | 146 (20.8%) | <0.001 |
| outcome_revascularisation_90days | 2773 (45.6%) | 2545 (47.3%) | 228 (32.5%) | <0.001 |
export2word(x = Descr_table,
file = here(tables_output_dir, paste0("Tab1-descr-all-midwall_LGE_presence-",Sys.Date(), ".docx")),
which.table="descr", nmax=TRUE, header.labels=c(),
caption=NULL, strip=FALSE, first.strip=FALSE, background="#D2D2D2",
size=NULL, header.background=NULL, header.color=NULL)# Parametric test (t-test)
t_test_LVEF <- t.test(
subset(df_all, CMR_LGE_midwall_presence == "A_No_midwall_LGE")$CMR_LVEF,
subset(df_all, CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE")$CMR_LVEF
)
# Non-parametric test (Wilcoxon test)
wilcox_test_LVEF <- wilcox.test(
subset(df_all, CMR_LGE_midwall_presence == "A_No_midwall_LGE")$CMR_LVEF,
subset(df_all, CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE")$CMR_LVEF
)
# Create a combined dataset for plotting
combined_data_LVEF <- df_all %>%
filter(CMR_LGE_midwall_presence %in% c("A_No_midwall_LGE", "B_Presence_of_midwall_LGE")) %>%
mutate(Group = case_when(
CMR_LGE_midwall_presence == "A_No_midwall_LGE" ~ "No Midwall LGE",
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE" ~ "Midwall LGE"
))
# Generate a density plot using ggplot2
ggplot(combined_data_LVEF, aes(x = CMR_LVEF, color = Group, fill = Group)) +
geom_density(alpha = 0.4) +
labs(title = "Density Plot of CMR_LVEF by Midwall LGE Presence",
x = "CMR_LVEF") +
theme_minimal() +
annotate("text", x = -Inf, y = Inf, label = paste0("t-test p-value: ", round(t_test_LVEF$p.value, 3)), hjust = -0.1, vjust = 1.5, size = 5, color = "black") +
annotate("text", x = -Inf, y = Inf, label = paste0("Wilcoxon p-value: ", round(wilcox_test_LVEF$p.value, 3)), hjust = -0.1, vjust = 3, size = 5, color = "black")
### LVEDV
# Parametric test (t-test)
t_test_LVEDV <- t.test(
subset(df_all, CMR_LGE_midwall_presence == "A_No_midwall_LGE")$CMR_LVEDV,
subset(df_all, CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE")$CMR_LVEDV
)
# Non-parametric test (Wilcoxon test)
wilcox_test_LVEDV <- wilcox.test(
subset(df_all, CMR_LGE_midwall_presence == "A_No_midwall_LGE")$CMR_LVEDV,
subset(df_all, CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE")$CMR_LVEDV
)
# Create a combined dataset for plotting
combined_data_LVEDV <- df_all %>%
filter(CMR_LGE_midwall_presence %in% c("A_No_midwall_LGE", "B_Presence_of_midwall_LGE")) %>%
mutate(Group = case_when(
CMR_LGE_midwall_presence == "A_No_midwall_LGE" ~ "No Midwall LGE",
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE" ~ "Midwall LGE"
))
# Generate a density plot using ggplot2
ggplot(combined_data_LVEDV, aes(x = CMR_LVEDV, color = Group, fill = Group)) +
geom_density(alpha = 0.4) +
labs(title = "Density Plot of CMR_LVEDV by Midwall LGE Presence",
x = "CMR_LVEDV") +
theme_minimal() +
annotate("text", x = -Inf, y = Inf, label = paste0("t-test p-value: ", round(t_test_LVEDV$p.value, 3)), hjust = -0.1, vjust = 1.5, size = 5, color = "black") +
annotate("text", x = -Inf, y = Inf, label = paste0("Wilcoxon p-value: ", round(wilcox_test_LVEDV$p.value, 3)), hjust = -0.1, vjust = 3, size = 5, color = "black")
### Tab2-descr-all-center
Descr_table = createTable(compareGroups(
demo_center ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
CMR_LVEF + CMR_LVEDV +
CMR_LVESV + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_ischemic_presence +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_midwall_presence +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical +
outcome_revascularisation_90days,
data = df_all,
method = 1, conf.level = 0.95),
hide.no = "No",
show.all=T, show.p.overall = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| [ALL] | ICPS | Lariboisiere | p.overall | |
|---|---|---|---|---|
| N=6082 | N=5214 | N=868 | ||
| demo_age | 64.5 (11.8) | 64.4 (11.9) | 65.3 (11.4) | 0.026 |
| demo_gender | 4419 (72.7%) | 3738 (71.7%) | 681 (78.5%) | <0.001 |
| demo_BMI | 27.7 (5.33) | 27.7 (5.34) | 27.8 (5.24) | 0.658 |
| CV_risk_diabete | 2309 (38.0%) | 1850 (35.5%) | 459 (52.9%) | <0.001 |
| CV_risk_HTA | 3144 (51.7%) | 2698 (51.7%) | 446 (51.4%) | 0.872 |
| CV_risk_obesity | 1687 (27.7%) | 1452 (27.8%) | 235 (27.1%) | 0.667 |
| CV_risk_dyslipidemia | 3005 (49.4%) | 2571 (49.3%) | 434 (50.0%) | 0.734 |
| CV_risk_Smoking | 1285 (21.1%) | 1092 (20.9%) | 193 (22.2%) | 0.413 |
| history_med_MI | 2354 (38.7%) | 1929 (37.0%) | 425 (49.0%) | <0.001 |
| history_coronary_procedure | 5394 (88.7%) | 4657 (89.3%) | 737 (84.9%) | <0.001 |
| history_interv_PCI | 380 (6.25%) | 278 (5.33%) | 102 (11.8%) | <0.001 |
| history_interv_CABG | 5085 (83.6%) | 4439 (85.1%) | 646 (74.4%) | <0.001 |
| med_periph_atheroma | 344 (5.66%) | 294 (5.64%) | 50 (5.76%) | 0.949 |
| history_stroke | 186 (3.06%) | 160 (3.07%) | 26 (3.00%) | 0.992 |
| med_pacemaker | 41 (0.67%) | 37 (0.71%) | 4 (0.46%) | 0.545 |
| med_CKD | 121 (1.99%) | 111 (2.13%) | 10 (1.15%) | 0.076 |
| history_hospit_HF | 368 (6.05%) | 306 (5.87%) | 62 (7.14%) | 0.167 |
| history_AFib | 453 (7.45%) | 395 (7.58%) | 58 (6.68%) | 0.390 |
| clini_NYHA | 753 (12.4%) | 645 (12.4%) | 108 (12.4%) | 0.997 |
| clini_cardiac_rythm | 426 (7.00%) | 367 (7.04%) | 59 (6.80%) | 0.852 |
| CMR_LVEF | 43.7 (5.70) | 43.8 (5.53) | 43.1 (6.61) | 0.003 |
| CMR_LVEDV | 103 (21.5) | 103 (20.9) | 104 (25.0) | 0.189 |
| CMR_LVESV | 58.6 (17.8) | 58.4 (17.3) | 59.9 (20.3) | 0.035 |
| CMR_LV_mass | 91.0 (19.5) | 91.0 (19.4) | 91.6 (19.8) | 0.399 |
| CMR_RV_dysfunction | 218 (3.58%) | 174 (3.34%) | 44 (5.07%) | 0.015 |
| CMR_LGE_ischemic_presence: | <0.001 | |||
| No_ischemic_LGE | 2491 (41.0%) | 2314 (44.4%) | 177 (20.4%) | |
| Presence_of_ischemic_LGE | 3591 (59.0%) | 2900 (55.6%) | 691 (79.6%) | |
| CMR_LGE_ischemic_extent_count | 1.83 (1.96) | 1.74 (1.96) | 2.37 (1.85) | <0.001 |
| CMR_LGE_ischemic_transmurality: | <0.001 | |||
| A_No_ischemic_LGE | 2491 (41.0%) | 2314 (44.4%) | 177 (20.4%) | |
| B_Subendocardial<50% | 1698 (27.9%) | 1355 (26.0%) | 343 (39.5%) | |
| C_Subendocardial≥50% | 1549 (25.5%) | 1268 (24.3%) | 281 (32.4%) | |
| D_Transmural | 344 (5.66%) | 277 (5.31%) | 67 (7.72%) | |
| CMR_LGE_ischemic_location_4: | <0.001 | |||
| A_No_ischemic_LGE | 2491 (41.0%) | 2314 (44.4%) | 177 (20.4%) | |
| B_Neither_anterior_nor_septal | 2662 (43.8%) | 2136 (41.0%) | 526 (60.6%) | |
| C_Anterior_without_septal | 422 (6.94%) | 351 (6.73%) | 71 (8.18%) | |
| D_Septal | 507 (8.34%) | 413 (7.92%) | 94 (10.8%) | |
| CMR_LGE_midwall_presence: | <0.001 | |||
| A_No_midwall_LGE | 5380 (88.5%) | 4581 (87.9%) | 799 (92.1%) | |
| B_Presence_of_midwall_LGE | 702 (11.5%) | 633 (12.1%) | 69 (7.95%) | |
| CMR_LGE_midwall_extent_count | 0.13 (0.39) | 0.14 (0.39) | 0.10 (0.35) | 0.001 |
| CMR_LGE_midwall_location_3: | 0.002 | |||
| No_midwall_LGE | 5380 (88.5%) | 4581 (87.9%) | 799 (92.1%) | |
| Midwall_LGE_not_at_risk | 471 (7.74%) | 426 (8.17%) | 45 (5.18%) | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 231 (3.80%) | 207 (3.97%) | 24 (2.76%) | |
| CMR_LGE_midwall_location_4: | 0.004 | |||
| No_midwall_LGE | 5380 (88.5%) | 4581 (87.9%) | 799 (92.1%) | |
| Midwall_LGE_not_at_risk | 471 (7.74%) | 426 (8.17%) | 45 (5.18%) | |
| Lateral_midwall_LGE | 118 (1.94%) | 104 (1.99%) | 14 (1.61%) | |
| Septal_Midwall_LGE | 113 (1.86%) | 103 (1.98%) | 10 (1.15%) | |
| CMR_LGE_midwall_anterior | 140 (2.30%) | 132 (2.53%) | 8 (0.92%) | 0.005 |
| CMR_LGE_midwall_septal | 113 (1.86%) | 103 (1.98%) | 10 (1.15%) | 0.127 |
| CMR_LGE_midwall_inferior | 212 (3.49%) | 191 (3.66%) | 21 (2.42%) | 0.080 |
| CMR_LGE_midwall_lateral | 124 (2.04%) | 110 (2.11%) | 14 (1.61%) | 0.407 |
| CMR_LGE_midwall_apical | 146 (2.40%) | 127 (2.44%) | 19 (2.19%) | 0.749 |
| outcome_revascularisation_90days | 2773 (45.6%) | 2235 (42.9%) | 538 (62.0%) | <0.001 |
df_selected <- df_all %>%
mutate(
surv.event = Surv(
time = outcome_FU_time_death,
event = outcome_death
),
CMR_LVEF_5 = CMR_LVEF/5,
CMR_LVEDV_5 = CMR_LVEDV/10,
CMR_LVESV_5 = CMR_LVESV/10
)
model <- coxph(formula = surv.event ~ CMR_LGE_midwall_presence, data = df_selected)
print("CMR_LGE_midwall_presence univariate analysis for all-cause death")## [1] "CMR_LGE_midwall_presence univariate analysis for all-cause death"
Descr_table = createTable(compareGroups(
surv.event ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
outcome_revascularisation_90days +
CMR_LVEF_5 + CMR_LVEDV_5 +
CMR_LVESV_5 + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_presence_ischemic_and_midwall +
CMR_LGE_ischemic_presence +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_extent_categ +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_ischemic_anterior +
CMR_LGE_ischemic_septal +
CMR_LGE_ischemic_inferior +
CMR_LGE_ischemic_lateral +
CMR_LGE_ischemic_Apical +
CMR_LGE_midwall_presence +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_extent_categ +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical,
data= df_selected,
method = 1, conf.level = 0.95),
hide.no = "No",
show.ratio =T, show.p.ratio = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| No event | Event | HR | p.ratio | p.overall | |
|---|---|---|---|---|---|
| N=5430 | N=652 | ||||
| demo_age | 64.1 (11.8) | 68.3 (11.3) | 1.03 [1.02;1.04] | <0.001 | <0.001 |
| demo_gender | 3843 (70.8%) | 576 (88.3%) | 2.83 [2.23;3.59] | <0.001 | 0.000 |
| demo_BMI | 27.7 (5.30) | 27.8 (5.57) | 1.01 [0.99;1.02] | 0.490 | 0.490 |
| CV_risk_diabete | 1945 (35.8%) | 364 (55.8%) | 2.09 [1.79;2.44] | <0.001 | 0.000 |
| CV_risk_HTA | 2817 (51.9%) | 327 (50.2%) | 0.92 [0.79;1.07] | 0.277 | 0.276 |
| CV_risk_obesity | 1509 (27.8%) | 178 (27.3%) | 0.98 [0.82;1.16] | 0.804 | 0.805 |
| CV_risk_dyslipidemia | 2677 (49.3%) | 328 (50.3%) | 1.04 [0.89;1.21] | 0.637 | 0.634 |
| CV_risk_Smoking | 1137 (20.9%) | 148 (22.7%) | 1.08 [0.90;1.30] | 0.401 | 0.402 |
| history_med_MI | 2090 (38.5%) | 264 (40.5%) | 1.08 [0.92;1.26] | 0.342 | 0.341 |
| history_coronary_procedure | 4817 (88.7%) | 577 (88.5%) | 0.98 [0.77;1.25] | 0.878 | 0.879 |
| history_interv_PCI | 310 (5.71%) | 70 (10.7%) | 1.74 [1.35;2.24] | <0.001 | <0.001 |
| history_interv_CABG | 4566 (84.1%) | 519 (79.6%) | 0.78 [0.64;0.95] | 0.011 | 0.011 |
| med_periph_atheroma | 276 (5.08%) | 68 (10.4%) | 1.97 [1.53;2.53] | <0.001 | <0.001 |
| history_stroke | 150 (2.76%) | 36 (5.52%) | 1.92 [1.37;2.69] | <0.001 | <0.001 |
| med_pacemaker | 38 (0.70%) | 3 (0.46%) | 0.71 [0.23;2.21] | 0.556 | 0.555 |
| med_CKD | 84 (1.55%) | 37 (5.67%) | 3.98 [2.86;5.55] | <0.001 | 0.000 |
| history_hospit_HF | 286 (5.27%) | 82 (12.6%) | 2.32 [1.84;2.92] | <0.001 | <0.001 |
| history_AFib | 382 (7.03%) | 71 (10.9%) | 1.60 [1.25;2.05] | <0.001 | <0.001 |
| clini_NYHA | 668 (12.3%) | 85 (13.0%) | 1.02 [0.81;1.28] | 0.885 | 0.884 |
| clini_cardiac_rythm | 368 (6.78%) | 58 (8.90%) | 1.34 [1.02;1.75] | 0.036 | 0.034 |
| outcome_revascularisation_90days | 2525 (46.5%) | 248 (38.0%) | 0.73 [0.62;0.85] | <0.001 | <0.001 |
| CMR_LVEF_5 | 8.79 (1.12) | 8.43 (1.28) | 0.82 [0.77;0.87] | <0.001 | <0.001 |
| CMR_LVEDV_5 | 10.3 (2.12) | 10.6 (2.40) | 1.05 [1.02;1.09] | 0.002 | 0.002 |
| CMR_LVESV_5 | 5.82 (1.75) | 6.19 (1.96) | 1.09 [1.05;1.13] | <0.001 | <0.001 |
| CMR_LV_mass | 91.1 (19.5) | 90.9 (19.5) | 1.00 [1.00;1.00] | 0.772 | 0.772 |
| CMR_RV_dysfunction | 153 (2.82%) | 65 (9.97%) | 3.32 [2.57;4.29] | <0.001 | 0.000 |
| CMR_LGE_presence_ischemic_and_midwall | 223 (4.11%) | 131 (20.1%) | 4.44 [3.66;5.38] | <0.001 | 0.000 |
| CMR_LGE_ischemic_presence: | 0.000 | ||||
| No_ischemic_LGE | 2388 (44.0%) | 103 (15.8%) | Ref. | Ref. | |
| Presence_of_ischemic_LGE | 3042 (56.0%) | 549 (84.2%) | 3.76 [3.05;4.64] | <0.001 | |
| CMR_LGE_ischemic_extent_count | 1.53 (1.66) | 4.30 (2.44) | 1.70 [1.65;1.76] | <0.001 | <0.001 |
| CMR_LGE_ischemic_extent_categ: | 0.000 | ||||
| A_No_ischemic_LGE | 2388 (44.0%) | 103 (15.8%) | Ref. | Ref. | |
| B_1_2_segments | 1369 (25.2%) | 23 (3.53%) | 0.41 [0.26;0.64] | <0.001 | |
| C_3_5_segments | 1659 (30.6%) | 294 (45.1%) | 3.64 [2.91;4.55] | <0.001 | |
| D_more6_segments | 14 (0.26%) | 232 (35.6%) | 27.7 [22.0;35.0] | <0.001 | |
| CMR_LGE_ischemic_transmurality: | 0.000 | ||||
| A_No_ischemic_LGE | 2388 (44.0%) | 103 (15.8%) | Ref. | Ref. | |
| B_Subendocardial<50% | 1619 (29.8%) | 79 (12.1%) | 1.14 [0.85;1.53] | 0.386 | |
| C_Subendocardial≥50% | 1290 (23.8%) | 259 (39.7%) | 4.06 [3.23;5.10] | <0.001 | |
| D_Transmural | 133 (2.45%) | 211 (32.4%) | 16.7 [13.2;21.1] | <0.001 | |
| CMR_LGE_ischemic_location_4: | 0.000 | ||||
| A_No_ischemic_LGE | 2388 (44.0%) | 103 (15.8%) | Ref. | Ref. | |
| B_Neither_anterior_nor_septal | 2563 (47.2%) | 99 (15.2%) | 0.89 [0.67;1.17] | 0.395 | |
| C_Anterior_without_septal | 317 (5.84%) | 105 (16.1%) | 6.40 [4.88;8.40] | <0.001 | |
| D_Septal | 162 (2.98%) | 345 (52.9%) | 19.4 [15.5;24.1] | <0.001 | |
| CMR_LGE_ischemic_anterior | 384 (7.07%) | 402 (61.7%) | 12.4 [10.6;14.5] | <0.001 | 0.000 |
| CMR_LGE_ischemic_septal | 162 (2.98%) | 345 (52.9%) | 14.6 [12.5;17.0] | <0.001 | 0.000 |
| CMR_LGE_ischemic_inferior | 1097 (20.2%) | 117 (17.9%) | 0.88 [0.72;1.08] | 0.218 | 0.216 |
| CMR_LGE_ischemic_lateral | 966 (17.8%) | 229 (35.1%) | 2.20 [1.87;2.59] | <0.001 | 0.000 |
| CMR_LGE_ischemic_Apical | 875 (16.1%) | 293 (44.9%) | 3.54 [3.03;4.13] | <0.001 | 0.000 |
| CMR_LGE_midwall_presence: | 0.000 | ||||
| A_No_midwall_LGE | 4901 (90.3%) | 479 (73.5%) | Ref. | Ref. | |
| B_Presence_of_midwall_LGE | 529 (9.74%) | 173 (26.5%) | 2.85 [2.39;3.39] | <0.001 | |
| CMR_LGE_midwall_extent_count | 0.10 (0.31) | 0.39 (0.71) | 2.63 [2.35;2.95] | <0.001 | <0.001 |
| CMR_LGE_midwall_extent_categ: | 0.000 | ||||
| None | 4901 (90.3%) | 479 (73.5%) | Ref. | Ref. | |
| Low_=1 | 510 (9.39%) | 100 (15.3%) | 1.88 [1.52;2.33] | <0.001 | |
| High_>1 | 19 (0.35%) | 73 (11.2%) | 10.3 [8.03;13.2] | <0.001 | |
| CMR_LGE_midwall_location_3: | 0.000 | ||||
| No_midwall_LGE | 4901 (90.3%) | 479 (73.5%) | Ref. | Ref. | |
| Midwall_LGE_not_at_risk | 406 (7.48%) | 65 (9.97%) | 1.53 [1.18;1.98] | 0.001 | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 123 (2.27%) | 108 (16.6%) | 5.94 [4.81;7.32] | <0.001 | |
| CMR_LGE_midwall_location_4: | 0.000 | ||||
| No_midwall_LGE | 4901 (90.3%) | 479 (73.5%) | Ref. | Ref. | |
| Midwall_LGE_not_at_risk | 406 (7.48%) | 65 (9.97%) | 1.53 [1.18;1.98] | 0.001 | |
| Lateral_midwall_LGE | 64 (1.18%) | 54 (8.28%) | 6.03 [4.55;7.99] | <0.001 | |
| Septal_Midwall_LGE | 59 (1.09%) | 54 (8.28%) | 5.84 [4.40;7.77] | <0.001 | |
| CMR_LGE_midwall_anterior | 113 (2.08%) | 27 (4.14%) | 1.62 [1.10;2.39] | 0.015 | 0.012 |
| CMR_LGE_midwall_septal | 59 (1.09%) | 54 (8.28%) | 5.16 [3.90;6.85] | <0.001 | 0.000 |
| CMR_LGE_midwall_inferior | 166 (3.06%) | 46 (7.06%) | 2.46 [1.82;3.32] | <0.001 | <0.001 |
| CMR_LGE_midwall_lateral | 64 (1.18%) | 60 (9.20%) | 5.75 [4.41;7.50] | <0.001 | 0.000 |
| CMR_LGE_midwall_apical | 132 (2.43%) | 14 (2.15%) | 0.79 [0.46;1.34] | 0.382 | 0.370 |
df <- df_all %>% mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>% select(
event, time,
demo_age, demo_gender, demo_BMI , CV_risk_diabete , CV_risk_Smoking , CV_risk_HTA, CV_risk_Smoking, CV_risk_dyslipidemia , history_hospit_HF, history_AFib, med_CKD, history_med_MI , CMR_LVEF_5, CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_presence, CMR_LGE_midwall_location_3, CMR_LGE_midwall_extent_count, outcome_revascularisation_90days) %>% droplevels()
# Define models
models <- list(
model1 = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LVEF_5)),
model2 = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_ischemic_extent_count)),
model3A = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_presence)),
model3B = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_location_3)),
model3C = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_extent_count))
)
# Extract model statistics and combine
model_stats <- lapply(models, extract_model_stats) # adaptation possible to have more decimals
# Rename the columns in each dataframe to include the model name
model_stats_named <- lapply(names(model_stats), function(model_name) {
data <- model_stats[[model_name]]
# Ensure row names are in a column (if not already)
if (!"A_Variable" %in% colnames(data)) {
data$A_Variable <- rownames(data)
}
# Rename other columns to include the model name for uniqueness
colnames(data)[-which(colnames(data) == "A_Variable")] <- paste(colnames(data)[-which(colnames(data) == "A_Variable")], model_name, sep = "_")
return(data)
})
# Combine all models using full_join, join by 'Variable'
combined_models <- purrr::reduce(model_stats_named, full_join, by = "A_Variable")
# Set 'Variable' as rownames and remove 'Variable' from the dataframe columns
rownames(combined_models) <- combined_models$A_Variable
combined_models$A_Variable <- NULL
# export in html
knitr::kable(combined_models, caption = "Models multi- all pop (N=6,082)", format = "html") %>%
kableExtra::kable_styling(full_width = F, bootstrap_options = c("striped", "hover", "condensed", "bordered"))| HR_CI_model1 | p_value_model1 | HR_CI_model2 | p_value_model2 | HR_CI_model3A | p_value_model3A | HR_CI_model3B | p_value_model3B | HR_CI_model3C | p_value_model3C | |
|---|---|---|---|---|---|---|---|---|---|---|
| demo_age | 1.03 ( 1.03 - 1.04 ) | <0.001 | 1.02 ( 1.02 - 1.03 ) | <0.001 | 1.02 ( 1.01 - 1.03 ) | <0.001 | 1.02 ( 1.01 - 1.03 ) | <0.001 | 1.02 ( 1.01 - 1.03 ) | <0.001 |
| demo_genderYes | 2.69 ( 2.11 - 3.43 ) | <0.001 | 2.24 ( 1.76 - 2.86 ) | <0.001 | 2.29 ( 1.80 - 2.92 ) | <0.001 | 2.29 ( 1.80 - 2.92 ) | <0.001 | 2.33 ( 1.82 - 2.97 ) | <0.001 |
| demo_BMI | 1.01 ( 0.99 - 1.02 ) | 0.543 | 1.01 ( 1.00 - 1.03 ) | 0.167 | 1.01 ( 0.99 - 1.03 ) | 0.324 | 1.01 ( 0.99 - 1.03 ) | 0.173 | 1.01 ( 0.99 - 1.02 ) | 0.475 |
| CV_risk_diabeteYes | 1.94 ( 1.65 - 2.28 ) | <0.001 | 1.56 ( 1.33 - 1.83 ) | <0.001 | 1.56 ( 1.33 - 1.83 ) | <0.001 | 1.52 ( 1.30 - 1.79 ) | <0.001 | 1.51 ( 1.28 - 1.77 ) | <0.001 |
| CV_risk_SmokingYes | 1.27 ( 1.05 - 1.54 ) | 0.015 | 1.25 ( 1.03 - 1.52 ) | 0.025 | 1.29 ( 1.06 - 1.57 ) | 0.011 | 1.26 ( 1.03 - 1.54 ) | 0.022 | 1.25 ( 1.02 - 1.52 ) | 0.028 |
| CV_risk_HTAYes | 0.76 ( 0.64 - 0.89 ) | <0.001 | 0.78 ( 0.66 - 0.92 ) | 0.004 | 0.76 ( 0.64 - 0.90 ) | 0.001 | 0.79 ( 0.67 - 0.93 ) | 0.006 | 0.79 ( 0.67 - 0.93 ) | 0.006 |
| CV_risk_dyslipidemiaYes | 0.98 ( 0.84 - 1.15 ) | 0.827 | 0.99 ( 0.84 - 1.16 ) | 0.877 | 1.03 ( 0.88 - 1.21 ) | 0.734 | 1.05 ( 0.89 - 1.23 ) | 0.562 | 1.07 ( 0.91 - 1.25 ) | 0.424 |
| history_hospit_HFYes | 1.69 ( 1.32 - 2.16 ) | <0.001 | 1.27 ( 0.98 - 1.64 ) | 0.068 | 1.35 ( 1.05 - 1.74 ) | 0.021 | 1.26 ( 0.98 - 1.64 ) | 0.073 | 1.41 ( 1.09 - 1.83 ) | 0.008 |
| history_AFibYes | 1.02 ( 0.79 - 1.31 ) | 0.903 | 0.95 ( 0.74 - 1.23 ) | 0.723 | 0.98 ( 0.76 - 1.27 ) | 0.898 | 0.94 ( 0.73 - 1.22 ) | 0.667 | 1.00 ( 0.77 - 1.29 ) | 0.976 |
| med_CKDYes | 2.82 ( 2.00 - 3.99 ) | <0.001 | 2.64 ( 1.87 - 3.73 ) | <0.001 | 2.66 ( 1.88 - 3.75 ) | <0.001 | 2.78 ( 1.97 - 3.92 ) | <0.001 | 2.70 ( 1.91 - 3.81 ) | <0.001 |
| history_med_MIYes | 1.02 ( 0.86 - 1.19 ) | 0.854 | 1.00 ( 0.85 - 1.17 ) | 0.982 | 0.99 ( 0.84 - 1.16 ) | 0.865 | 0.99 ( 0.84 - 1.17 ) | 0.898 | 0.99 ( 0.84 - 1.16 ) | 0.860 |
| CMR_LVEF_5 | 0.90 ( 0.85 - 0.96 ) | 0.002 | 0.93 ( 0.87 - 0.99 ) | 0.023 | 0.95 ( 0.89 - 1.01 ) | 0.111 | 0.96 ( 0.90 - 1.02 ) | 0.172 | 0.95 ( 0.89 - 1.01 ) | 0.088 |
| CMR_LGE_ischemic_extent_count | NA | NA | 1.63 ( 1.57 - 1.68 ) | <0.001 | 1.60 ( 1.54 - 1.65 ) | <0.001 | 1.59 ( 1.54 - 1.65 ) | <0.001 | 1.59 ( 1.54 - 1.65 ) | <0.001 |
| CMR_LGE_midwall_presenceB_Presence_of_midwall_LGE | NA | NA | NA | NA | 2.45 ( 2.05 - 2.93 ) | <0.001 | NA | NA | NA | NA |
| CMR_LGE_midwall_location_3Midwall_LGE_not_at_risk | NA | NA | NA | NA | NA | NA | 1.49 ( 1.14 - 1.95 ) | 0.003 | NA | NA |
| CMR_LGE_midwall_location_3At_risk_midwall_LGE_(septal_and/or_lateral) | NA | NA | NA | NA | NA | NA | 3.92 ( 3.16 - 4.87 ) | <0.001 | NA | NA |
| CMR_LGE_midwall_extent_count | NA | NA | NA | NA | NA | NA | NA | NA | 2.05 ( 1.83 - 2.30 ) | <0.001 |
combined_models$A_Variable <- rownames(combined_models)
# Make A_Variable the first column
combined_models <- combined_models %>%
select(A_Variable, everything())
# Export in word
ft <- flextable(combined_models)
ft <- set_table_properties(ft, layout = "autofit")
doc <- read_docx() %>%
body_add_par("Model full - all pop (N=6,082)", style = "heading 1") %>%
body_add_flextable(ft)
print(doc, target = here(tables_output_dir,paste0("Tab4-multi-all-death-",Sys.Date(), ".docx")))function could be improved (probably since there is bootstrapping etc, the ideal would be to save somewhere the results and to recalculate only if parameters changes). For the future me. “Supplementary Figure 3. Incremental prognostic value of the presence of midwall-LGE in the overall population (N=6,082)”
var_base = c("demo_age", "demo_gender" , "demo_BMI" , "CV_risk_diabete" , "CV_risk_HTA", "CV_risk_Smoking" , "CV_risk_dyslipidemia" , "history_hospit_HF", "history_AFib" , "med_CKD" , "history_med_MI" , "CMR_LVEF")
var_added = c("CMR_LGE_ischemic_extent_count",
"CMR_LGE_midwall_presence")
D <- incremental_function(
df = df_all,
event = "outcome_death",
time = "outcome_FU_time_death",
time_analyzed = median(df_all$outcome_FU_time_death/12), # big debate on which value to use (use in NRI and IDI)
var_1 = var_base,
var_2 = c(var_base,c("CMR_LGE_ischemic_extent_count")),
var_3 = c(var_base,c("CMR_LGE_ischemic_extent_count",
"CMR_LGE_midwall_presence")))## [1] 6082 69
## $var_1
## [1] "demo_age" "demo_gender" "demo_BMI"
## [4] "CV_risk_diabete" "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF" "history_AFib"
## [10] "med_CKD" "history_med_MI" "CMR_LVEF"
##
## $var_2
## [1] "demo_age" "demo_gender"
## [3] "demo_BMI" "CV_risk_diabete"
## [5] "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF"
## [9] "history_AFib" "med_CKD"
## [11] "history_med_MI" "CMR_LVEF"
## [13] "CMR_LGE_ischemic_extent_count"
##
## $var_3
## [1] "demo_age" "demo_gender"
## [3] "demo_BMI" "CV_risk_diabete"
## [5] "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF"
## [9] "history_AFib" "med_CKD"
## [11] "history_med_MI" "CMR_LVEF"
## [13] "CMR_LGE_ischemic_extent_count" "CMR_LGE_midwall_presence"
##
## [1] "modelmodel_1"
## [1] "modelmodel_2"
## [1] "modelmodel_3"
## [1] "analysis CHI2"
## [1] "testChi2 = 340.27, LR test 0.0000"
## [1] "testChi2 = 1104.35, LR test 0.0000"
## [1] "testChi2 = 1187.95, LR test 0.0000"
## [1] "analysis CHI2 comparaison"
## [1] "analysis c index"
## [1] "analysis c index comparaison"
## [1] "Analysis of models NRI et IDI basics"
## [1] "Analysis of models NRI et IDI comparaison"
## $chi2_null
## $chi2_null$model_1
## [1] "Chi2 = 340.27, LR test 0.0000"
##
## $chi2_null$model_2
## [1] "Chi2 = 1104.35, LR test 0.0000"
##
## $chi2_null$model_3
## [1] "Chi2 = 1187.95, LR test 0.0000"
##
##
## $chi2_comparison
## $chi2_comparison$`Comparison 1 vs 2`
## [1] "Chi2 = 764.08, LR test 0.0000"
##
## $chi2_comparison$`Comparison 2 vs 3`
## [1] "Chi2 = 83.60, LR test 0.0000"
##
##
## $concordance
## $concordance$`Model 1`
## [1] "0.71, 95%CI(0.68-0.73)"
##
## $concordance$`Model 2`
## [1] "0.83, 95%CI(0.81-0.85)"
##
## $concordance$`Model 3`
## [1] "0.84, 95%CI(0.83-0.86)"
##
##
## $c_index_comparison
## $c_index_comparison$`Comparison of Model 1 and Model 2`
## [1] "C-index: 0.706243765247869, P-value: 0"
## [2] "C-index: 0.827081520174292, P-value: 0"
##
## $c_index_comparison$`Comparison of Model 2 and Model 3`
## [1] "C-index: 0.827081520174292, P-value: 2.6839446605198e-06"
## [2] "C-index: 0.84244256279206, P-value: 2.6839446605198e-06"
##
##
## $nri_idi_basic
## $nri_idi_basic$`Comparison of Model 2 and Model 1`
## $nri_idi_basic$`Comparison of Model 2 and Model 1`$IDI
## 2.5% 97.5%
## 0.1510709 0.1225705 0.1858774 0.0000000
##
## $nri_idi_basic$`Comparison of Model 2 and Model 1`$NRI
## 2.5% 97.5%
## 0.4065624 0.3582640 0.4709355 0.0000000
##
##
## $nri_idi_basic$`Comparison of Model 3 and Model 1`
## $nri_idi_basic$`Comparison of Model 3 and Model 1`$IDI
## 2.5% 97.5%
## 0.1652517 0.1358757 0.2033350 0.0000000
##
## $nri_idi_basic$`Comparison of Model 3 and Model 1`$NRI
## 2.5% 97.5%
## 0.4451703 0.3942912 0.5000170 0.0000000
##
##
##
## $nri_idi_comparison
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`$IDI
## 2.5% 97.5%
## 0.1510709 0.1225705 0.1858774 0.0000000
##
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`$NRI
## 2.5% 97.5%
## 0.4065624 0.3582640 0.4709355 0.0000000
##
##
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`$IDI
## 2.5% 97.5%
## 0.01417917 0.00359631 0.02670306 0.00000000
##
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`$NRI
## 2.5% 97.5%
## 0.16119124 0.02878297 0.20298412 0.03322259
” Panel A central figure”
# Data parameters
results <- createSurvivalPlot(
data = df_all,
compared_with = "CMR_LGE_midwall_presence",
time = "outcome_FU_time_death",
event = "outcome_death",
my_colors = c("#25A26B","#FF002B"),
confint_choosen = 0.95,
mytitle = "Fig1: LGE presence (all pop = 6,082)"
)## [1] "Cox model formula: Surv(outcome_FU_time_death/12, outcome_death) ~ CMR_LGE_midwall_presence"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig1-all-KM-Midwall_presence_plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig1-all-KM-Midwall_presence_presence_risk-", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)” Suppl figure S2”
# Data parameters
results <- createSurvivalPlot(
data = df_all,
compared_with = "CMR_LGE_type",
time = "outcome_FU_time_death",
event = "outcome_death",
my_colors = c("#25A26B","#4292C6","#FF002B","#2C3E50"),
confint_choosen = 0.95,
mytitle = "Fig2: LGE type (all pop = 6,082)"
)## [1] "Cox model formula: Surv(outcome_FU_time_death/12, outcome_death) ~ CMR_LGE_type"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig2-all-KM-LGE_type_plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig2-all-KM-LGE_type_risk-", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)### BY EXTENT
# Data
df_selected <- df_all %>%
mutate(
outcome = outcome_death,
outcome_FU_time_death = outcome_FU_time_death,
variable_to_group = CMR_LGE_ischemic_extent_categ,
variable_of_interest = CMR_LGE_midwall_presence
)
# Parameters # Set the title for the graph
mytitle <- c("Ischemic LGE extent by midwall - all (N=6082)")
my_colors <- c("#25A26B","#FF002B")
confint_choosen = 0.95
# ANNUALISE / py à faire en jour !
py1 <- pyears(Surv(outcome_FU_time_death*(365/12), outcome_death) ~ variable_to_group, data = df_selected, subset = df_selected$variable_of_interest == "A_No_midwall_LGE", data.frame = T) # change here for the categories you want to divide
df1 <- py1$data
df1$MidW <- c(rep("A_No_midwall_LGE",4))
df1$annual_rates <- round(100*(df1$event/df1$pyears), 2) # give pourcentage
py2 <- pyears(Surv(outcome_FU_time_death*(365/12), outcome_death) ~ variable_to_group, data = df_selected, subset = df_selected$variable_of_interest == "B_Presence_of_midwall_LGE", data.frame = T)
df2 <- py2$data
df2$annual_rates <- round(100*(df2$event/df2$pyears), 2) # give pourcentage
df2$MidW <- c(rep("B_Presence_of_midwall_LGE",4))
df_add <- rbind(df1, df2) # fused two df
# The graph
gg_graph <- ggplot(data = df_add,
aes(x = variable_to_group, y = annual_rates, fill = MidW, label = annual_rates)) +
geom_bar(position="dodge", stat='identity')+
scale_fill_manual(values = adjustcolor(my_colors, alpha.f = 0.8)) +
labs(
x = "LGE Extent (in categories of segments)",
y = "Annualized event rate (%)",
fill = "Presence of Midwall" )+
ggtitle(mytitle)+
geom_text(
aes(x = variable_to_group, y = annual_rates, label = annual_rates, group = MidW),
position = position_dodge(width = 1),
vjust = -0.5, size = 4, fontface = "bold") +
scale_y_continuous(expand = c(0, 1), limits = c(0,15), breaks = seq(0, 17.5, 2.5)) + # Here to change the size of graphics
theme_bw()+
theme(
panel.grid.major = element_line(color = "gray", size = 0.2, linetype = "dotted"),
panel.grid.minor = element_line(color = "gray", size = 0.2, linetype = "dotted"),
plot.title = element_text(hjust = 0.5),
axis.title.x = element_blank(),
# axis.text.x = element_blank(), to remove the x axis legend
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.text.y = element_text(size = 12, face = "bold"),
panel.border = element_blank(),
legend.position = c(0.1, 0.9), # Move the legend to the top-left corner
legend.justification = c(0, 1), # Anchor the legend to the top-left corner
legend.text = element_text(size = 12), # Adjust the legend text size
legend.title = element_text(size = 14) # Adjust the legend title size
)
gg_graphggsave(
filename = here(figures_output_dir, paste0("Fig3a-all-death_rate_extent-", Sys.Date(),".png")),
plot = gg_graph, width = 6, height = 6, units = "in", dpi = 600)
# Compare subgroups
print(df_add) # u see the dataframe used to build the graph## variable_to_group pyears n event MidW
## 1 A_No_ischemic_LGE 19491.0666 2143 61 A_No_midwall_LGE
## 2 B_1_2_segments 11579.4855 1282 17 A_No_midwall_LGE
## 3 C_3_5_segments 15913.4337 1774 232 A_No_midwall_LGE
## 4 D_more6_segments 1418.4451 181 169 A_No_midwall_LGE
## 5 A_No_ischemic_LGE 3140.1825 348 42 B_Presence_of_midwall_LGE
## 6 B_1_2_segments 959.0931 110 6 B_Presence_of_midwall_LGE
## 7 C_3_5_segments 1539.1125 179 62 B_Presence_of_midwall_LGE
## 8 D_more6_segments 425.7917 65 63 B_Presence_of_midwall_LGE
## annual_rates
## 1 0.31
## 2 0.15
## 3 1.46
## 4 11.91
## 5 1.34
## 6 0.63
## 7 4.03
## 8 14.80
n_values <- c(1, 2, 3, 4) # now i want to compare by 2 therefore i use this method
for (n in n_values) {
rate_comp <- ratedifference(df_add$event[n + 4], df_add$event[n], df_add$pyears[n + 4], df_add$pyears[n], CRC = TRUE, conf.level = 0.95)
value <- as.character(rate_comp$p.value)
result <- ifelse(rate_comp$p.value < 0.001 | rate_comp$p.value == 0, "<0.001", value)
print(result)
}## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 4.200000e+01 3.140183e+03 1.337502e-02 9.330025e-03 1.742001e-02
## Unexposed 6.100000e+01 1.949107e+04 3.129639e-03 2.344263e-03 3.915014e-03
## Total 1.030000e+02 2.263125e+04 4.551229e-03 3.672291e-03 5.430167e-03
## [1] "<0.001"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 6.000000e+00 9.590931e+02 6.255910e-03 1.250231e-03 1.126159e-02
## Unexposed 1.700000e+01 1.157949e+04 1.468114e-03 7.702295e-04 2.165998e-03
## Total 2.300000e+01 1.253858e+04 1.834339e-03 1.084680e-03 2.583998e-03
## [1] "0.0633545991244964"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 6.200000e+01 1.539112e+03 4.028296e-02 3.025590e-02 5.031001e-02
## Unexposed 2.320000e+02 1.591343e+04 1.457888e-02 1.270290e-02 1.645486e-02
## Total 2.940000e+02 1.745255e+04 1.684568e-02 1.492009e-02 1.877127e-02
## [1] "<0.001"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 63.0000000 425.7916952 0.1479597 0.1114237 0.1844957
## Unexposed 169.0000000 1418.4451289 0.1191445 0.1011815 0.1371075
## Total 232.0000000 1844.2368241 0.1257973 0.1096100 0.1419846
## [1] "0.165384424094627"
####### BY PATTERN
# Data
df_selected <- df_all %>%
mutate(
outcome = outcome_death,
outcome_FU_time_death = outcome_FU_time_death,
variable_to_group = CMR_LGE_ischemic_transmurality,
variable_of_interest = CMR_LGE_midwall_presence
)
# Parameters # Set the title for the graph
mytitle <- c("Ischemic LGE pattern by midwall - all (N=6082)")
my_colors <- c("#25A26B","#FF002B")
confint_choosen = 0.95
# ANNUALISE / py à faire en jour !
py1 <- pyears(Surv(outcome_FU_time_death*(365/12), outcome_death) ~ variable_to_group, data = df_selected, subset = df_selected$variable_of_interest == "A_No_midwall_LGE", data.frame = T) # change here for the categories you want to divide
df1 <- py1$data
df1$MidW <- c(rep("A_No_midwall_LGE",4))
df1$annual_rates <- round(100*(df1$event/df1$pyears), 2) # give pourcentage
py2 <- pyears(Surv(outcome_FU_time_death*(365/12), outcome_death) ~ variable_to_group, data = df_selected, subset = df_selected$variable_of_interest == "B_Presence_of_midwall_LGE", data.frame = T)
df2 <- py2$data
df2$annual_rates <- round(100*(df2$event/df2$pyears), 2) # give pourcentage
df2$MidW <- c(rep("B_Presence_of_midwall_LGE",4))
df_add <- rbind(df1, df2) # fused two df
# The graph
gg_graph <- ggplot(data = df_add,
aes(x = variable_to_group, y = annual_rates, fill = MidW, label = annual_rates)) +
geom_bar(position="dodge", stat='identity')+
scale_fill_manual(values = adjustcolor(my_colors, alpha.f = 0.8)) +
labs(
x = "LGE Extent (in categories of segments)",
y = "Annualized event rate (%)",
fill = "Presence of Midwall" )+
ggtitle(mytitle)+
geom_text(
aes(x = variable_to_group, y = annual_rates, label = annual_rates, group = MidW),
position = position_dodge(width = 1),
vjust = -0.5, size = 4, fontface = "bold") +
scale_y_continuous(expand = c(0, 1), limits = c(0,15), breaks = seq(0, 17.5, 2.5)) + # Here to change the size of graphics
theme_bw()+
theme(
panel.grid.major = element_line(color = "gray", size = 0.2, linetype = "dotted"),
panel.grid.minor = element_line(color = "gray", size = 0.2, linetype = "dotted"),
plot.title = element_text(hjust = 0.5),
axis.title.x = element_blank(),
# axis.text.x = element_blank(), to remove the x axis legend
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.text.y = element_text(size = 12, face = "bold"),
panel.border = element_blank(),
legend.position = c(0.1, 0.9), # Move the legend to the top-left corner
legend.justification = c(0, 1), # Anchor the legend to the top-left corner
legend.text = element_text(size = 12), # Adjust the legend text size
legend.title = element_text(size = 14) # Adjust the legend title size
)
gg_graphggsave(
filename = here(figures_output_dir, paste0("Fig3b-all-death_rate_transmurality-", Sys.Date(),".png")),
plot = gg_graph, width = 6, height = 6, units = "in", dpi = 600)
# Compare subgroups
print(df_add) # u see the dataframe used to build the graph## variable_to_group pyears n event MidW
## 1 A_No_ischemic_LGE 19491.067 2143 61 A_No_midwall_LGE
## 2 B_Subendocardial<50% 14215.430 1572 59 A_No_midwall_LGE
## 3 C_Subendocardial≥50% 12448.973 1392 204 A_No_midwall_LGE
## 4 D_Transmural 2246.961 273 155 A_No_midwall_LGE
## 5 A_No_ischemic_LGE 3140.183 348 42 B_Presence_of_midwall_LGE
## 6 B_Subendocardial<50% 1052.363 126 20 B_Presence_of_midwall_LGE
## 7 C_Subendocardial≥50% 1308.021 157 55 B_Presence_of_midwall_LGE
## 8 D_Transmural 563.614 71 56 B_Presence_of_midwall_LGE
## annual_rates
## 1 0.31
## 2 0.42
## 3 1.64
## 4 6.90
## 5 1.34
## 6 1.90
## 7 4.20
## 8 9.94
n_values <- c(1, 2, 3, 4) # now i want to compare by 2 therefore i use this method
for (n in n_values) {
rate_comp <- ratedifference(df_add$event[n + 4], df_add$event[n], df_add$pyears[n + 4], df_add$pyears[n], CRC = TRUE, conf.level = 0.95)
value <- as.character(rate_comp$p.value)
result <- ifelse(rate_comp$p.value < 0.001 | rate_comp$p.value == 0, "<0.001", value)
print(result)
}## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 4.200000e+01 3.140183e+03 1.337502e-02 9.330025e-03 1.742001e-02
## Unexposed 6.100000e+01 1.949107e+04 3.129639e-03 2.344263e-03 3.915014e-03
## Total 1.030000e+02 2.263125e+04 4.551229e-03 3.672291e-03 5.430167e-03
## [1] "<0.001"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 2.000000e+01 1.052363e+03 1.900486e-02 1.067576e-02 2.733395e-02
## Unexposed 5.900000e+01 1.421543e+04 4.150420e-03 3.091375e-03 5.209464e-03
## Total 7.900000e+01 1.526779e+04 5.174291e-03 4.033292e-03 6.315290e-03
## [1] "<0.001"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 5.500000e+01 1.308021e+03 4.204826e-02 3.093568e-02 5.316084e-02
## Unexposed 2.040000e+02 1.244897e+04 1.638689e-02 1.413820e-02 1.863558e-02
## Total 2.590000e+02 1.375699e+04 1.882679e-02 1.653394e-02 2.111963e-02
## [1] "<0.001"
## Cases Person-time Incidence rates Lower CL Upper CL
## Exposed 5.600000e+01 5.636140e+02 9.935879e-02 7.333561e-02 1.253820e-01
## Unexposed 1.550000e+02 2.246961e+03 6.898206e-02 5.812235e-02 7.984178e-02
## Total 2.110000e+02 2.810575e+03 7.507361e-02 6.494396e-02 8.520325e-02
## [1] "0.034739222982505"
” Suppl figure S3”
# Data parameters
df <- df_all %>%
mutate(
HTA_LGE = case_when(
CMR_LGE_midwall_presence == "A_No_midwall_LGE" & CV_risk_HTA == "Yes" ~ "A LGE MW - ; HTA +",
CMR_LGE_midwall_presence == "A_No_midwall_LGE" & CV_risk_HTA == "No" ~ "B LGE MW - ; HTA -",
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE" & CV_risk_HTA == "Yes" ~ "C LGE MW + ; HTA +",
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE" & CV_risk_HTA == "No" ~ "D LGE MW + ; HTA -",
TRUE ~ NA_character_
)
)
results <- createSurvivalPlot(
data = df,
compared_with = "HTA_LGE",
time = "outcome_FU_time_death",
event = "outcome_death",
my_colors = c("#25A26B","orange4","#FF002B","#2C3E50"),
confint_choosen = 0.95,
mytitle = "Fig4: LGE x HTA (all pop = 6,082)"
)## [1] "Cox model formula: Surv(outcome_FU_time_death/12, outcome_death) ~ HTA_LGE"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig4-all-KM-LGE_HTA-plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig4-all-KM-LGE_HTA-plot", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)Find a way to save this plot
library(forestplot)
# function
df_selected <- df_all %>%
mutate(
demo_age_categ = factor(case_when(
demo_age < 65 ~ "age<65",
TRUE ~ "age≥65"
), levels = c("age<65", "age≥65")),
CMR_LVEF_categ = factor(ifelse(
CMR_LVEF <= 40, "HFrEF", "HFmrEF"
), levels = c("HFrEF", "HFmrEF"))
)
print("Forest plot")## [1] "Forest plot"
D <- forest_function(
df = df_selected,
time_var = "outcome_FU_time_death",
event_var = "outcome_death",
var_of_interest = "CMR_LGE_midwall_presence",
"demo_age_categ",
"demo_gender",
"CV_risk_obesity",
"CV_risk_diabete",
"CV_risk_HTA",
"CV_risk_Smoking",
"clini_NYHA",
"CMR_LVEF_categ"
)
base_data <- D
name_row_vector <- c("Age","<65 years", "≥65 years", "Gender","Female", "Male", "Body Mass Index ","No obesity", "Obesity", "Diabete mellitus", "No", "Yes", "Hypertension", "No", "Yes", "Smoking", "No", "Yes", "Symptoms", "Asymptomatic","Symptomatic", "LVEF","≤40%", ">40%")
base_data$name <- name_row_vector
# png(here(figures_output_dir,paste0("Fig5-forestplot", Sys.Date(),".png")), width = 10, height = 5, dpi = 300)
# Generate the forestplot
forest_plot <- base_data |>
forestplot(
labeltext = c(name, ratio1, ratio2, OR, Pval, PValInter),
graph.pos = 4,
mean = mean,
upper = upper,
lower = lower,
is.summary = FALSE, # c(rep(TRUE, 2), rep(c(TRUE, FALSE, FALSE), 8)), #Make Text Bold to highlight Summary rows
boxsize = 0.2, # Adjust the boxsize as needed)
clip = c(0, 7), #Lower and upper limits for clipping confidence intervals to arrows
align = c("r", "c", "c", "r","l", "l"), # make it work
vertices = TRUE,
xlog = FALSE, #Log scale on X axis
col = fpColors(box = "royalblue",
line = "darkblue",
summary = "royalblue")) |>
fp_set_zebra_style("#EFEFEF", ignore_subheaders = FALSE)|>
fp_set_style(box = "red",
line = "gray0",
summary = "royalblue",
align = "lrrr")
print(forest_plot)” Suppl table S3”
df <- df_all %>% filter(CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE") %>% droplevels()
Descr_table = createTable(compareGroups(
CMR_LGE_midwall_location_3 ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
CMR_LVEF + CMR_LVEDV +
CMR_LVESV + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_presence_ischemic_and_midwall +
CMR_LGE_ischemic_presence +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_extent_categ +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_extent_categ +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical +
outcome_revascularisation_90days,
data= df,
method = 1, conf.level = 0.95),
hide.no = "No",
show.all=T, show.p.overall = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| [ALL] | Midwall_LGE_not_at_risk | At_risk_midwall_LGE_(septal_and/or_lateral) | p.overall | |
|---|---|---|---|---|
| N=702 | N=471 | N=231 | ||
| demo_age | 65.8 (11.6) | 65.3 (11.7) | 66.9 (11.2) | 0.074 |
| demo_gender | 525 (74.8%) | 340 (72.2%) | 185 (80.1%) | 0.030 |
| demo_BMI | 28.3 (5.43) | 28.7 (5.74) | 27.4 (4.63) | 0.001 |
| CV_risk_diabete | 324 (46.2%) | 218 (46.3%) | 106 (45.9%) | 0.985 |
| CV_risk_HTA | 479 (68.2%) | 345 (73.2%) | 134 (58.0%) | <0.001 |
| CV_risk_obesity | 228 (32.5%) | 170 (36.1%) | 58 (25.1%) | 0.005 |
| CV_risk_dyslipidemia | 386 (55.0%) | 268 (56.9%) | 118 (51.1%) | 0.169 |
| CV_risk_Smoking | 141 (20.1%) | 85 (18.0%) | 56 (24.2%) | 0.068 |
| history_med_MI | 272 (38.7%) | 188 (39.9%) | 84 (36.4%) | 0.409 |
| history_coronary_procedure | 619 (88.2%) | 415 (88.1%) | 204 (88.3%) | 1.000 |
| history_interv_PCI | 44 (6.27%) | 30 (6.37%) | 14 (6.06%) | 1.000 |
| history_interv_CABG | 584 (83.2%) | 392 (83.2%) | 192 (83.1%) | 1.000 |
| med_periph_atheroma | 46 (6.55%) | 26 (5.52%) | 20 (8.66%) | 0.157 |
| history_stroke | 21 (2.99%) | 14 (2.97%) | 7 (3.03%) | 1.000 |
| med_pacemaker | 13 (1.85%) | 8 (1.70%) | 5 (2.16%) | 0.767 |
| med_CKD | 28 (3.99%) | 17 (3.61%) | 11 (4.76%) | 0.598 |
| history_hospit_HF | 36 (5.13%) | 24 (5.10%) | 12 (5.19%) | 1.000 |
| history_AFib | 76 (10.8%) | 47 (9.98%) | 29 (12.6%) | 0.367 |
| clini_NYHA | 72 (10.3%) | 51 (10.8%) | 21 (9.09%) | 0.562 |
| clini_cardiac_rythm | 66 (9.40%) | 40 (8.49%) | 26 (11.3%) | 0.298 |
| CMR_LVEF | 43.3 (5.78) | 43.5 (5.70) | 43.0 (5.93) | 0.349 |
| CMR_LVEDV | 104 (21.6) | 103 (21.1) | 105 (22.8) | 0.394 |
| CMR_LVESV | 59.6 (17.6) | 59.2 (17.3) | 60.5 (18.2) | 0.363 |
| CMR_LV_mass | 93.5 (17.8) | 94.0 (17.5) | 92.5 (18.5) | 0.306 |
| CMR_RV_dysfunction | 30 (4.27%) | 16 (3.40%) | 14 (6.06%) | 0.150 |
| CMR_LGE_presence_ischemic_and_midwall | 354 (50.4%) | 231 (49.0%) | 123 (53.2%) | 0.334 |
| CMR_LGE_ischemic_presence: | 0.334 | |||
| No_ischemic_LGE | 348 (49.6%) | 240 (51.0%) | 108 (46.8%) | |
| Presence_of_ischemic_LGE | 354 (50.4%) | 231 (49.0%) | 123 (53.2%) | |
| CMR_LGE_ischemic_extent_count | 1.83 (2.26) | 1.59 (2.06) | 2.31 (2.56) | <0.001 |
| CMR_LGE_ischemic_extent_categ: | <0.001 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 240 (51.0%) | 108 (46.8%) | |
| B_1_2_segments | 110 (15.7%) | 91 (19.3%) | 19 (8.23%) | |
| C_3_5_segments | 179 (25.5%) | 112 (23.8%) | 67 (29.0%) | |
| D_more6_segments | 65 (9.26%) | 28 (5.94%) | 37 (16.0%) | |
| CMR_LGE_ischemic_transmurality: | 0.038 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 240 (51.0%) | 108 (46.8%) | |
| B_Subendocardial<50% | 126 (17.9%) | 84 (17.8%) | 42 (18.2%) | |
| C_Subendocardial≥50% | 157 (22.4%) | 110 (23.4%) | 47 (20.3%) | |
| D_Transmural | 71 (10.1%) | 37 (7.86%) | 34 (14.7%) | |
| CMR_LGE_ischemic_location_4: | <0.001 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 240 (51.0%) | 108 (46.8%) | |
| B_Neither_anterior_nor_septal | 217 (30.9%) | 168 (35.7%) | 49 (21.2%) | |
| C_Anterior_without_septal | 43 (6.13%) | 22 (4.67%) | 21 (9.09%) | |
| D_Septal | 94 (13.4%) | 41 (8.70%) | 53 (22.9%) | |
| CMR_LGE_midwall_extent_count | 1.14 (0.37) | 1.08 (0.29) | 1.26 (0.48) | <0.001 |
| CMR_LGE_midwall_extent_categ: | <0.001 | |||
| Low_=1 | 610 (86.9%) | 437 (92.8%) | 173 (74.9%) | |
| High_>1 | 92 (13.1%) | 34 (7.22%) | 58 (25.1%) | |
| CMR_LGE_midwall_location_3: | <0.001 | |||
| Midwall_LGE_not_at_risk | 471 (67.1%) | 471 (100%) | 0 (0.00%) | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 231 (32.9%) | 0 (0.00%) | 231 (100%) | |
| CMR_LGE_midwall_location_4: | <0.001 | |||
| Midwall_LGE_not_at_risk | 471 (67.1%) | 471 (100%) | 0 (0.00%) | |
| Lateral_midwall_LGE | 118 (16.8%) | 0 (0.00%) | 118 (51.1%) | |
| Septal_Midwall_LGE | 113 (16.1%) | 0 (0.00%) | 113 (48.9%) | |
| CMR_LGE_midwall_anterior | 140 (19.9%) | 136 (28.9%) | 4 (1.73%) | <0.001 |
| CMR_LGE_midwall_septal | 113 (16.1%) | 0 (0.00%) | 113 (48.9%) | <0.001 |
| CMR_LGE_midwall_inferior | 212 (30.2%) | 196 (41.6%) | 16 (6.93%) | <0.001 |
| CMR_LGE_midwall_lateral | 124 (17.7%) | 0 (0.00%) | 124 (53.7%) | <0.001 |
| CMR_LGE_midwall_apical | 146 (20.8%) | 144 (30.6%) | 2 (0.87%) | <0.001 |
| outcome_revascularisation_90days | 228 (32.5%) | 164 (34.8%) | 64 (27.7%) | 0.071 |
export2word(x = Descr_table,
file = here(tables_output_dir, paste0("Tab6-descr-all-LGE_midwall_location-",Sys.Date(), ".docx")),
which.table="descr", nmax=TRUE, header.labels=c(),
caption=NULL, strip=FALSE, first.strip=FALSE, background="#D2D2D2",
size=NULL, header.background=NULL, header.color=NULL)” Suppl table S34
df <- df_all %>% filter(CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE") %>% droplevels()
Descr_table = createTable(compareGroups(
CMR_LGE_ischemic_presence ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
CMR_LVEF + CMR_LVEDV +
CMR_LVESV + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_presence_ischemic_and_midwall +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_extent_categ +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_extent_categ +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical +
outcome_revascularisation_90days,
data= df,
method = 1, conf.level = 0.95),
hide.no = "No",
show.all=T, show.p.overall = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| [ALL] | No_ischemic_LGE | Presence_of_ischemic_LGE | p.overall | |
|---|---|---|---|---|
| N=702 | N=348 | N=354 | ||
| demo_age | 65.8 (11.6) | 65.2 (11.6) | 66.4 (11.5) | 0.147 |
| demo_gender | 525 (74.8%) | 251 (72.1%) | 274 (77.4%) | 0.128 |
| demo_BMI | 28.3 (5.43) | 28.1 (5.29) | 28.4 (5.58) | 0.466 |
| CV_risk_diabete | 324 (46.2%) | 143 (41.1%) | 181 (51.1%) | 0.010 |
| CV_risk_HTA | 479 (68.2%) | 234 (67.2%) | 245 (69.2%) | 0.632 |
| CV_risk_obesity | 228 (32.5%) | 110 (31.6%) | 118 (33.3%) | 0.684 |
| CV_risk_dyslipidemia | 386 (55.0%) | 188 (54.0%) | 198 (55.9%) | 0.665 |
| CV_risk_Smoking | 141 (20.1%) | 72 (20.7%) | 69 (19.5%) | 0.763 |
| history_med_MI | 272 (38.7%) | 141 (40.5%) | 131 (37.0%) | 0.380 |
| history_coronary_procedure | 619 (88.2%) | 312 (89.7%) | 307 (86.7%) | 0.277 |
| history_interv_PCI | 44 (6.27%) | 15 (4.31%) | 29 (8.19%) | 0.049 |
| history_interv_CABG | 584 (83.2%) | 301 (86.5%) | 283 (79.9%) | 0.026 |
| med_periph_atheroma | 46 (6.55%) | 21 (6.03%) | 25 (7.06%) | 0.691 |
| history_stroke | 21 (2.99%) | 12 (3.45%) | 9 (2.54%) | 0.629 |
| med_pacemaker | 13 (1.85%) | 10 (2.87%) | 3 (0.85%) | 0.087 |
| med_CKD | 28 (3.99%) | 17 (4.89%) | 11 (3.11%) | 0.312 |
| history_hospit_HF | 36 (5.13%) | 14 (4.02%) | 22 (6.21%) | 0.252 |
| history_AFib | 76 (10.8%) | 41 (11.8%) | 35 (9.89%) | 0.493 |
| clini_NYHA | 72 (10.3%) | 36 (10.3%) | 36 (10.2%) | 1.000 |
| clini_cardiac_rythm | 66 (9.40%) | 37 (10.6%) | 29 (8.19%) | 0.328 |
| CMR_LVEF | 43.3 (5.78) | 43.7 (5.24) | 43.0 (6.24) | 0.099 |
| CMR_LVEDV | 104 (21.6) | 104 (22.7) | 104 (20.6) | 0.862 |
| CMR_LVESV | 59.6 (17.6) | 59.3 (17.7) | 60.0 (17.5) | 0.623 |
| CMR_LV_mass | 93.5 (17.8) | 93.6 (17.7) | 93.4 (18.0) | 0.891 |
| CMR_RV_dysfunction | 30 (4.27%) | 14 (4.02%) | 16 (4.52%) | 0.890 |
| CMR_LGE_presence_ischemic_and_midwall | 354 (50.4%) | 0 (0.00%) | 354 (100%) | <0.001 |
| CMR_LGE_ischemic_extent_count | 1.83 (2.26) | 0.00 (0.00) | 3.63 (1.91) | <0.001 |
| CMR_LGE_ischemic_extent_categ: | <0.001 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 348 (100%) | 0 (0.00%) | |
| B_1_2_segments | 110 (15.7%) | 0 (0.00%) | 110 (31.1%) | |
| C_3_5_segments | 179 (25.5%) | 0 (0.00%) | 179 (50.6%) | |
| D_more6_segments | 65 (9.26%) | 0 (0.00%) | 65 (18.4%) | |
| CMR_LGE_ischemic_transmurality: | <0.001 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 348 (100%) | 0 (0.00%) | |
| B_Subendocardial<50% | 126 (17.9%) | 0 (0.00%) | 126 (35.6%) | |
| C_Subendocardial≥50% | 157 (22.4%) | 0 (0.00%) | 157 (44.4%) | |
| D_Transmural | 71 (10.1%) | 0 (0.00%) | 71 (20.1%) | |
| CMR_LGE_ischemic_location_4: | <0.001 | |||
| A_No_ischemic_LGE | 348 (49.6%) | 348 (100%) | 0 (0.00%) | |
| B_Neither_anterior_nor_septal | 217 (30.9%) | 0 (0.00%) | 217 (61.3%) | |
| C_Anterior_without_septal | 43 (6.13%) | 0 (0.00%) | 43 (12.1%) | |
| D_Septal | 94 (13.4%) | 0 (0.00%) | 94 (26.6%) | |
| CMR_LGE_midwall_extent_count | 1.14 (0.37) | 1.08 (0.30) | 1.19 (0.43) | <0.001 |
| CMR_LGE_midwall_extent_categ: | <0.001 | |||
| Low_=1 | 610 (86.9%) | 321 (92.2%) | 289 (81.6%) | |
| High_>1 | 92 (13.1%) | 27 (7.76%) | 65 (18.4%) | |
| CMR_LGE_midwall_location_3: | 0.334 | |||
| Midwall_LGE_not_at_risk | 471 (67.1%) | 240 (69.0%) | 231 (65.3%) | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 231 (32.9%) | 108 (31.0%) | 123 (34.7%) | |
| CMR_LGE_midwall_location_4: | 0.491 | |||
| Midwall_LGE_not_at_risk | 471 (67.1%) | 240 (69.0%) | 231 (65.3%) | |
| Lateral_midwall_LGE | 118 (16.8%) | 53 (15.2%) | 65 (18.4%) | |
| Septal_Midwall_LGE | 113 (16.1%) | 55 (15.8%) | 58 (16.4%) | |
| CMR_LGE_midwall_anterior | 140 (19.9%) | 41 (11.8%) | 99 (28.0%) | <0.001 |
| CMR_LGE_midwall_septal | 113 (16.1%) | 55 (15.8%) | 58 (16.4%) | 0.915 |
| CMR_LGE_midwall_inferior | 212 (30.2%) | 112 (32.2%) | 100 (28.2%) | 0.292 |
| CMR_LGE_midwall_lateral | 124 (17.7%) | 54 (15.5%) | 70 (19.8%) | 0.168 |
| CMR_LGE_midwall_apical | 146 (20.8%) | 91 (26.1%) | 55 (15.5%) | 0.001 |
| outcome_revascularisation_90days | 228 (32.5%) | 0 (0.00%) | 228 (64.4%) | <0.001 |
export2word(x = Descr_table,
file = here(tables_output_dir, paste0("Tab7-descr-all-LGE_midwall_isch_add-",Sys.Date(), ".docx")),
which.table="descr", nmax=TRUE, header.labels=c(),
caption=NULL, strip=FALSE, first.strip=FALSE, background="#D2D2D2",
size=NULL, header.background=NULL, header.color=NULL)df_selected <- df_all %>%
filter(CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE") %>%
mutate(
surv.event = Surv(
time = outcome_FU_time_death,
event = outcome_death
),
CMR_LVEF_5 = CMR_LVEF/5,
CMR_LVEDV_5 = CMR_LVEDV/10,
CMR_LVESV_5 = CMR_LVESV/10
) %>% droplevels()
# location
model <- coxph(formula = surv.event ~ CMR_LGE_midwall_location_3, data = df_selected)
print("CMR_LGE_midwall_location_3 for all-cause death in midwall pop (N=702")## [1] "CMR_LGE_midwall_location_3 for all-cause death in midwall pop (N=702"
# extent
model <- coxph(formula = surv.event ~ CMR_LGE_midwall_extent_categ, data = df_selected)
print("CMR_LGE_midwall_extent_categ for all-cause death in midwall pop (N=702")## [1] "CMR_LGE_midwall_extent_categ for all-cause death in midwall pop (N=702"
# ischemic added
model <- coxph(formula = surv.event ~ CMR_LGE_ischemic_presence, data = df_selected)
print("CMR_LGE_ischemic_presence for all-cause death in midwall pop (N=702")## [1] "CMR_LGE_ischemic_presence for all-cause death in midwall pop (N=702"
Descr_table = createTable(compareGroups(
surv.event ~
demo_age + demo_gender + demo_BMI + CV_risk_diabete +
CV_risk_HTA + CV_risk_obesity + CV_risk_dyslipidemia + CV_risk_Smoking +
history_med_MI + history_coronary_procedure + history_interv_PCI +
history_interv_CABG + med_periph_atheroma + history_stroke +
med_pacemaker + med_CKD + history_hospit_HF + history_AFib + clini_NYHA +
clini_cardiac_rythm +
outcome_revascularisation_90days +
CMR_LVEF_5 + CMR_LVEDV_5 +
CMR_LVESV_5 + CMR_LV_mass + CMR_RV_dysfunction +
CMR_LGE_presence_ischemic_and_midwall +
CMR_LGE_ischemic_presence +
CMR_LGE_ischemic_extent_count +
CMR_LGE_ischemic_extent_categ +
CMR_LGE_ischemic_transmurality +
CMR_LGE_ischemic_location_4 +
CMR_LGE_ischemic_anterior +
CMR_LGE_ischemic_septal +
CMR_LGE_ischemic_inferior +
CMR_LGE_ischemic_lateral +
CMR_LGE_ischemic_Apical +
CMR_LGE_midwall_presence +
CMR_LGE_midwall_extent_count +
CMR_LGE_midwall_extent_categ +
CMR_LGE_midwall_location_3 +
CMR_LGE_midwall_location_4 +
CMR_LGE_midwall_anterior +
CMR_LGE_midwall_septal +
CMR_LGE_midwall_inferior +
CMR_LGE_midwall_lateral +
CMR_LGE_midwall_apical,
data= df_selected,
method = 1, conf.level = 0.95),
hide.no = "No",
show.ratio =T, show.p.ratio = T)
export2md(Descr_table, strip=TRUE, first.strip=TRUE)| No event | Event | HR | p.ratio | p.overall | |
|---|---|---|---|---|---|
| N=529 | N=173 | ||||
| demo_age | 64.9 (11.5) | 68.7 (11.2) | 1.02 [1.01;1.04] | 0.001 | 0.001 |
| demo_gender | 370 (69.9%) | 155 (89.6%) | 2.97 [1.82;4.84] | <0.001 | <0.001 |
| demo_BMI | 28.3 (5.60) | 28.2 (4.92) | 1.00 [0.98;1.03] | 0.834 | 0.834 |
| CV_risk_diabete | 231 (43.7%) | 93 (53.8%) | 1.54 [1.14;2.08] | 0.005 | 0.004 |
| CV_risk_HTA | 396 (74.9%) | 83 (48.0%) | 0.40 [0.29;0.54] | <0.001 | <0.001 |
| CV_risk_obesity | 174 (32.9%) | 54 (31.2%) | 0.95 [0.69;1.32] | 0.770 | 0.770 |
| CV_risk_dyslipidemia | 304 (57.5%) | 82 (47.4%) | 0.74 [0.55;0.99] | 0.045 | 0.043 |
| CV_risk_Smoking | 107 (20.2%) | 34 (19.7%) | 0.98 [0.67;1.42] | 0.903 | 0.903 |
| history_med_MI | 206 (38.9%) | 66 (38.2%) | 0.91 [0.67;1.24] | 0.546 | 0.538 |
| history_coronary_procedure | 467 (88.3%) | 152 (87.9%) | 0.98 [0.62;1.54] | 0.914 | 0.922 |
| history_interv_PCI | 27 (5.10%) | 17 (9.83%) | 1.53 [0.91;2.59] | 0.110 | 0.094 |
| history_interv_CABG | 447 (84.5%) | 137 (79.2%) | 0.81 [0.56;1.17] | 0.259 | 0.253 |
| med_periph_atheroma | 30 (5.67%) | 16 (9.25%) | 1.38 [0.82;2.31] | 0.220 | 0.216 |
| history_stroke | 15 (2.84%) | 6 (3.47%) | 0.90 [0.39;2.07] | 0.807 | 0.799 |
| med_pacemaker | 12 (2.27%) | 1 (0.58%) | 0.30 [0.04;2.17] | 0.234 | 0.207 |
| med_CKD | 21 (3.97%) | 7 (4.05%) | 1.67 [0.78;3.57] | 0.183 | 0.177 |
| history_hospit_HF | 21 (3.97%) | 15 (8.67%) | 2.00 [1.17;3.40] | 0.011 | 0.009 |
| history_AFib | 54 (10.2%) | 22 (12.7%) | 1.66 [1.06;2.60] | 0.027 | 0.026 |
| clini_NYHA | 52 (9.83%) | 20 (11.6%) | 1.10 [0.69;1.75] | 0.693 | 0.688 |
| clini_cardiac_rythm | 50 (9.45%) | 16 (9.25%) | 1.34 [0.80;2.25] | 0.265 | 0.265 |
| outcome_revascularisation_90days | 174 (32.9%) | 54 (31.2%) | 0.98 [0.71;1.35] | 0.906 | 0.907 |
| CMR_LVEF_5 | 8.76 (1.11) | 8.37 (1.24) | 0.83 [0.74;0.93] | 0.001 | 0.001 |
| CMR_LVEDV_5 | 10.3 (2.09) | 10.7 (2.36) | 1.06 [0.99;1.12] | 0.082 | 0.082 |
| CMR_LVESV_5 | 5.85 (1.71) | 6.31 (1.88) | 1.09 [1.01;1.17] | 0.020 | 0.020 |
| CMR_LV_mass | 94.4 (17.3) | 90.5 (19.1) | 0.99 [0.98;1.00] | 0.005 | 0.005 |
| CMR_RV_dysfunction | 16 (3.02%) | 14 (8.09%) | 2.59 [1.49;4.49] | 0.001 | <0.001 |
| CMR_LGE_presence_ischemic_and_midwall | 223 (42.2%) | 131 (75.7%) | 3.48 [2.46;4.93] | <0.001 | <0.001 |
| CMR_LGE_ischemic_presence: | <0.001 | ||||
| No_ischemic_LGE | 306 (57.8%) | 42 (24.3%) | Ref. | Ref. | |
| Presence_of_ischemic_LGE | 223 (42.2%) | 131 (75.7%) | 3.48 [2.46;4.93] | <0.001 | |
| CMR_LGE_ischemic_extent_count | 1.15 (1.60) | 3.90 (2.70) | 1.44 [1.36;1.52] | <0.001 | <0.001 |
| CMR_LGE_ischemic_extent_categ: | 0.000 | ||||
| A_No_ischemic_LGE | 306 (57.8%) | 42 (24.3%) | Ref. | Ref. | |
| B_1_2_segments | 104 (19.7%) | 6 (3.47%) | 0.48 [0.20;1.12] | 0.091 | |
| C_3_5_segments | 117 (22.1%) | 62 (35.8%) | 3.19 [2.15;4.72] | <0.001 | |
| D_more6_segments | 2 (0.38%) | 63 (36.4%) | 12.0 [8.09;17.8] | <0.001 | |
| CMR_LGE_ischemic_transmurality: | 0.000 | ||||
| A_No_ischemic_LGE | 306 (57.8%) | 42 (24.3%) | Ref. | Ref. | |
| B_Subendocardial<50% | 106 (20.0%) | 20 (11.6%) | 1.53 [0.90;2.60] | 0.120 | |
| C_Subendocardial≥50% | 102 (19.3%) | 55 (31.8%) | 3.13 [2.09;4.69] | <0.001 | |
| D_Transmural | 15 (2.84%) | 56 (32.4%) | 8.04 [5.38;12.0] | <0.001 | |
| CMR_LGE_ischemic_location_4: | 0.000 | ||||
| A_No_ischemic_LGE | 306 (57.8%) | 42 (24.3%) | Ref. | Ref. | |
| B_Neither_anterior_nor_septal | 192 (36.3%) | 25 (14.5%) | 0.95 [0.58;1.56] | 0.832 | |
| C_Anterior_without_septal | 16 (3.02%) | 27 (15.6%) | 7.26 [4.47;11.8] | <0.001 | |
| D_Septal | 15 (2.84%) | 79 (45.7%) | 11.3 [7.75;16.6] | <0.001 | |
| CMR_LGE_ischemic_anterior | 23 (4.35%) | 93 (53.8%) | 10.1 [7.44;13.8] | <0.001 | 0.000 |
| CMR_LGE_ischemic_septal | 15 (2.84%) | 79 (45.7%) | 8.62 [6.35;11.7] | <0.001 | 0.000 |
| CMR_LGE_ischemic_inferior | 76 (14.4%) | 29 (16.8%) | 1.02 [0.69;1.53] | 0.910 | 0.919 |
| CMR_LGE_ischemic_lateral | 71 (13.4%) | 51 (29.5%) | 2.07 [1.49;2.88] | <0.001 | <0.001 |
| CMR_LGE_ischemic_Apical | 67 (12.7%) | 68 (39.3%) | 3.15 [2.32;4.28] | <0.001 | <0.001 |
| CMR_LGE_midwall_presence: B_Presence_of_midwall_LGE | 529 (100%) | 173 (100%) | Ref. | Ref. | . |
| CMR_LGE_midwall_extent_count | 1.04 (0.19) | 1.46 (0.58) | 3.64 [2.92;4.54] | <0.001 | <0.001 |
| CMR_LGE_midwall_extent_categ: | 0.000 | ||||
| Low_=1 | 510 (96.4%) | 100 (57.8%) | Ref. | Ref. | |
| High_>1 | 19 (3.59%) | 73 (42.2%) | 5.53 [4.08;7.50] | <0.001 | |
| CMR_LGE_midwall_location_3: | 0.000 | ||||
| Midwall_LGE_not_at_risk | 406 (76.7%) | 65 (37.6%) | Ref. | Ref. | |
| At_risk_midwall_LGE_(septal_and/or_lateral) | 123 (23.3%) | 108 (62.4%) | 3.84 [2.82;5.22] | <0.001 | |
| CMR_LGE_midwall_location_4: | 0.000 | ||||
| Midwall_LGE_not_at_risk | 406 (76.7%) | 65 (37.6%) | Ref. | Ref. | |
| Lateral_midwall_LGE | 64 (12.1%) | 54 (31.2%) | 3.91 [2.72;5.61] | <0.001 | |
| Septal_Midwall_LGE | 59 (11.2%) | 54 (31.2%) | 3.77 [2.62;5.41] | <0.001 | |
| CMR_LGE_midwall_anterior | 113 (21.4%) | 27 (15.6%) | 0.64 [0.43;0.97] | 0.036 | 0.032 |
| CMR_LGE_midwall_septal | 59 (11.2%) | 54 (31.2%) | 2.51 [1.82;3.46] | <0.001 | <0.001 |
| CMR_LGE_midwall_inferior | 166 (31.4%) | 46 (26.6%) | 0.98 [0.70;1.38] | 0.921 | 0.928 |
| CMR_LGE_midwall_lateral | 64 (12.1%) | 60 (34.7%) | 2.90 [2.12;3.98] | <0.001 | <0.001 |
| CMR_LGE_midwall_apical | 132 (25.0%) | 14 (8.09%) | 0.29 [0.17;0.50] | <0.001 | <0.001 |
“Part of Table 3”
df <- df_all %>%
filter(
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE"
) %>%
mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>%
select(
event, time,
demo_age, demo_gender, demo_BMI , CV_risk_diabete , CV_risk_Smoking , CV_risk_HTA, CV_risk_Smoking, CV_risk_dyslipidemia , history_hospit_HF, history_AFib, med_CKD, history_med_MI , CMR_LVEF_5, CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_location_3, CMR_LGE_midwall_extent_count
) %>%
droplevels()
# Define models
models <- list(
model1 = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LVEF_5)),
model2 = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_ischemic_extent_count)),
model4 = coxph(Surv(time, event) ~ ., data = df %>% select(event:CMR_LGE_midwall_extent_count))
)
# Extract model statistics and combine
model_stats <- lapply(models, extract_model_stats) # adaptation possible to have more decimals
# Rename the columns in each dataframe to include the model name
model_stats_named <- lapply(names(model_stats), function(model_name) {
data <- model_stats[[model_name]]
# Ensure row names are in a column (if not already)
if (!"A_Variable" %in% colnames(data)) {
data$A_Variable <- rownames(data)
}
# Rename other columns to include the model name for uniqueness
colnames(data)[-which(colnames(data) == "A_Variable")] <- paste(colnames(data)[-which(colnames(data) == "A_Variable")], model_name, sep = "_")
return(data)
})
# Combine all models using full_join, join by 'Variable'
combined_models <- purrr::reduce(model_stats_named, full_join, by = "A_Variable")
# Set 'Variable' as rownames and remove 'Variable' from the dataframe columns
rownames(combined_models) <- combined_models$A_Variable
combined_models$A_Variable <- NULL
# export in html
knitr::kable(combined_models, caption = "Models multi- midwall pop (N=702)", format = "html") %>%
kableExtra::kable_styling(full_width = F, bootstrap_options = c("striped", "hover", "condensed", "bordered"))| HR_CI_model1 | p_value_model1 | HR_CI_model2 | p_value_model2 | HR_CI_model4 | p_value_model4 | |
|---|---|---|---|---|---|---|
| demo_age | 1.03 ( 1.02 - 1.05 ) | <0.001 | 1.02 ( 1.00 - 1.03 ) | 0.015 | 1.01 ( 1.00 - 1.03 ) | 0.065 |
| demo_genderYes | 2.63 ( 1.60 - 4.32 ) | <0.001 | 2.79 ( 1.70 - 4.60 ) | <0.001 | 2.67 ( 1.61 - 4.42 ) | <0.001 |
| demo_BMI | 1.02 ( 0.99 - 1.05 ) | 0.199 | 1.02 ( 0.98 - 1.05 ) | 0.376 | 1.03 ( 0.99 - 1.06 ) | 0.140 |
| CV_risk_diabeteYes | 1.38 ( 1.01 - 1.89 ) | 0.042 | 1.30 ( 0.95 - 1.77 ) | 0.100 | 1.09 ( 0.79 - 1.51 ) | 0.583 |
| CV_risk_SmokingYes | 1.07 ( 0.72 - 1.60 ) | 0.724 | 1.22 ( 0.81 - 1.84 ) | 0.337 | 1.10 ( 0.73 - 1.66 ) | 0.641 |
| CV_risk_HTAYes | 0.38 ( 0.27 - 0.52 ) | <0.001 | 0.52 ( 0.38 - 0.73 ) | <0.001 | 0.70 ( 0.49 - 0.99 ) | 0.042 |
| CV_risk_dyslipidemiaYes | 0.92 ( 0.67 - 1.26 ) | 0.607 | 1.01 ( 0.73 - 1.39 ) | 0.940 | 1.11 ( 0.80 - 1.53 ) | 0.537 |
| history_hospit_HFYes | 1.37 ( 0.76 - 2.48 ) | 0.299 | 1.12 ( 0.61 - 2.06 ) | 0.716 | 1.29 ( 0.70 - 2.37 ) | 0.420 |
| history_AFibYes | 1.04 ( 0.64 - 1.67 ) | 0.877 | 1.14 ( 0.69 - 1.87 ) | 0.605 | 1.11 ( 0.68 - 1.82 ) | 0.678 |
| med_CKDYes | 1.37 ( 0.63 - 3.01 ) | 0.428 | 1.71 ( 0.78 - 3.77 ) | 0.183 | 2.08 ( 0.94 - 4.61 ) | 0.072 |
| history_med_MIYes | 0.81 ( 0.59 - 1.11 ) | 0.190 | 0.78 ( 0.56 - 1.09 ) | 0.147 | 0.79 ( 0.57 - 1.11 ) | 0.173 |
| CMR_LVEF_5 | 0.91 ( 0.80 - 1.04 ) | 0.176 | 0.95 ( 0.83 - 1.10 ) | 0.508 | 0.95 ( 0.82 - 1.09 ) | 0.448 |
| CMR_LGE_ischemic_extent_count | NA | NA | 1.38 ( 1.30 - 1.47 ) | <0.001 | 1.33 ( 1.25 - 1.42 ) | <0.001 |
| CMR_LGE_midwall_location_3At_risk_midwall_LGE_(septal_and/or_lateral) | NA | NA | NA | NA | 2.38 ( 1.70 - 3.34 ) | <0.001 |
| CMR_LGE_midwall_extent_count | NA | NA | NA | NA | 2.19 ( 1.63 - 2.96 ) | <0.001 |
combined_models$A_Variable <- rownames(combined_models)
# Make A_Variable the first column
combined_models <- combined_models %>%
select(A_Variable, everything())
# Export in word
ft <- flextable(combined_models)
ft <- set_table_properties(ft, layout = "autofit")
doc <- read_docx() %>%
body_add_par("Model full - midwall pop (N=702)", style = "heading 1") %>%
body_add_flextable(ft)
print(doc, target = here(tables_output_dir,paste0("Tab9-multi-mid-death-",Sys.Date(), ".docx")))function could be improved (probably since there is bootstrapping etc, the ideal would be to save somewhere the results and to recalculate only if parameters changes). For the future me. “Supplementary Figure 3. Incremental prognostic value of the presence of midwall-LGE in the overall population (N=6,082)”
df <- df_all %>%
filter(
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE"
) %>%
mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>%
select(
event, time,
demo_age, demo_gender, demo_BMI , CV_risk_diabete , CV_risk_Smoking , CV_risk_HTA, CV_risk_Smoking, CV_risk_dyslipidemia , history_hospit_HF, history_AFib, med_CKD, history_med_MI , CMR_LVEF_5, CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_location_3, CMR_LGE_midwall_extent_count
) %>%
droplevels()
var_base = c("demo_age", "demo_gender" , "demo_BMI" , "CV_risk_diabete" , "CV_risk_HTA", "CV_risk_Smoking" , "CV_risk_dyslipidemia" , "history_hospit_HF", "history_AFib" , "med_CKD" , "history_med_MI" , "CMR_LVEF_5")
D <- incremental_function(
df = df,
event = "event",
time = "time",
time_analyzed = median(df_all$outcome_FU_time_death/12), # big debate on which value to use (use in NRI and IDI) > just for NRI and IDI
var_1 = var_base,
var_2 = c(var_base,c("CMR_LGE_ischemic_extent_count")),
var_3 = c(var_base,c("CMR_LGE_ischemic_extent_count", "CMR_LGE_midwall_location_3", "CMR_LGE_midwall_extent_count")))## [1] 702 17
## $var_1
## [1] "demo_age" "demo_gender" "demo_BMI"
## [4] "CV_risk_diabete" "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF" "history_AFib"
## [10] "med_CKD" "history_med_MI" "CMR_LVEF_5"
##
## $var_2
## [1] "demo_age" "demo_gender"
## [3] "demo_BMI" "CV_risk_diabete"
## [5] "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF"
## [9] "history_AFib" "med_CKD"
## [11] "history_med_MI" "CMR_LVEF_5"
## [13] "CMR_LGE_ischemic_extent_count"
##
## $var_3
## [1] "demo_age" "demo_gender"
## [3] "demo_BMI" "CV_risk_diabete"
## [5] "CV_risk_HTA" "CV_risk_Smoking"
## [7] "CV_risk_dyslipidemia" "history_hospit_HF"
## [9] "history_AFib" "med_CKD"
## [11] "history_med_MI" "CMR_LVEF_5"
## [13] "CMR_LGE_ischemic_extent_count" "CMR_LGE_midwall_location_3"
## [15] "CMR_LGE_midwall_extent_count"
##
## [1] "modelmodel_1"
## [1] "modelmodel_2"
## [1] "modelmodel_3"
## [1] "analysis CHI2"
## [1] "testChi2 = 94.07, LR test 0.0000"
## [1] "testChi2 = 207.72, LR test 0.0000"
## [1] "testChi2 = 275.52, LR test 0.0000"
## [1] "analysis CHI2 comparaison"
## [1] "analysis c index"
## [1] "analysis c index comparaison"
## [1] "Analysis of models NRI et IDI basics"
## [1] "Analysis of models NRI et IDI comparaison"
## $chi2_null
## $chi2_null$model_1
## [1] "Chi2 = 94.07, LR test 0.0000"
##
## $chi2_null$model_2
## [1] "Chi2 = 207.72, LR test 0.0000"
##
## $chi2_null$model_3
## [1] "Chi2 = 275.52, LR test 0.0000"
##
##
## $chi2_comparison
## $chi2_comparison$`Comparison 1 vs 2`
## [1] "Chi2 = 113.66, LR test 0.0000"
##
## $chi2_comparison$`Comparison 2 vs 3`
## [1] "Chi2 = 67.80, LR test 0.0000"
##
##
## $concordance
## $concordance$`Model 1`
## [1] "0.72, 95%CI(0.68-0.76)"
##
## $concordance$`Model 2`
## [1] "0.80, 95%CI(0.77-0.84)"
##
## $concordance$`Model 3`
## [1] "0.85, 95%CI(0.82-0.88)"
##
##
## $c_index_comparison
## $c_index_comparison$`Comparison of Model 1 and Model 2`
## [1] "C-index: 0.721180574480842, P-value: 6.46624409195162e-06"
## [2] "C-index: 0.8030195672317, P-value: 6.46624409195162e-06"
##
## $c_index_comparison$`Comparison of Model 2 and Model 3`
## [1] "C-index: 0.8030195672317, P-value: 9.58762472391683e-05"
## [2] "C-index: 0.852741592630948, P-value: 9.58762472391683e-05"
##
##
## $nri_idi_basic
## $nri_idi_basic$`Comparison of Model 2 and Model 1`
## $nri_idi_basic$`Comparison of Model 2 and Model 1`$IDI
## 2.5% 97.5%
## 0.14528694 0.08529046 0.21642709 0.00000000
##
## $nri_idi_basic$`Comparison of Model 2 and Model 1`$NRI
## 2.5% 97.5%
## 0.3710785 0.2409142 0.4818305 0.0000000
##
##
## $nri_idi_basic$`Comparison of Model 3 and Model 1`
## $nri_idi_basic$`Comparison of Model 3 and Model 1`$IDI
## 2.5% 97.5%
## 0.2030050 0.1372389 0.2758759 0.0000000
##
## $nri_idi_basic$`Comparison of Model 3 and Model 1`$NRI
## 2.5% 97.5%
## 0.4335756 0.3410519 0.5798233 0.0000000
##
##
##
## $nri_idi_comparison
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`$IDI
## 2.5% 97.5%
## 0.14528694 0.08529046 0.21642709 0.00000000
##
## $nri_idi_comparison$`Comparison of Model 1 and Model 2`$NRI
## 2.5% 97.5%
## 0.3710785 0.2409142 0.4818305 0.0000000
##
##
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`$IDI
## 2.5% 97.5%
## 0.05780747 0.01564579 0.10723032 0.01328904
##
## $nri_idi_comparison$`Comparison of Model 2 and Model 3`$NRI
## 2.5% 97.5%
## 0.2982533 0.1113014 0.3980479 0.0000000
” Panel B1 central figure”
df <- df_all %>%
filter(
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE"
) %>%
mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>%
select(
event, time,
demo_age, demo_gender, demo_BMI , CV_risk_diabete , CV_risk_Smoking , CV_risk_HTA, CV_risk_Smoking, CV_risk_dyslipidemia , history_hospit_HF, history_AFib, med_CKD, history_med_MI , CMR_LVEF_5, CMR_LGE_ischemic_extent_count, CMR_LGE_midwall_location_3, CMR_LGE_midwall_extent_count
) %>%
droplevels()
# Data parameters
results <- createSurvivalPlot(
data = df,
compared_with = "CMR_LGE_midwall_location_3",
show.pval = F,
time = "time",
event = "event",
my_colors = c("#FF002B","#2C3E50"),
confint_choosen = 0.95,
mytitle = "Fig6: midwall location (midwall pop = 702)"
)## [1] "Cox model formula: Surv(time/12, event) ~ CMR_LGE_midwall_location_3"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig6-mid-KM-LGE_midwall_location_plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig6-mid-KM-LGE_midwall_location_risk-", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)” Panel B2 central figure”
df <- df_all %>%
filter(
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE"
) %>%
mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>%
droplevels()
# Data parameters
results <- createSurvivalPlot(
data = df,
compared_with = "CMR_LGE_midwall_extent_categ",
show.pval = F,
time = "time",
event = "event",
my_colors = c("#FF002B","#2C3E50"),
confint_choosen = 0.95,
mytitle = "Fig7: midwall extent (midwall pop = 702)"
)## [1] "Cox model formula: Surv(time/12, event) ~ CMR_LGE_midwall_extent_categ"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig7-mid-KM-LGE_midwall_extent_plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig7-mid-KM-LGE_midwall_extent_risk-", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)” Panel B3 central figure”
df <- df_all %>%
filter(
CMR_LGE_midwall_presence == "B_Presence_of_midwall_LGE"
) %>%
mutate(
event = outcome_death,
time = outcome_FU_time_death,
CMR_LVEF_5 = CMR_LVEF/5
) %>%
droplevels()
# Data parameters
results <- createSurvivalPlot(
data = df,
compared_with = "CMR_LGE_ischemic_presence",
show.pval = F,
time = "time",
event = "event",
my_colors = c("#FF002B","#2C3E50"),
confint_choosen = 0.95,
mytitle = "Fig8: midwall with isch (midwall pop = 702)"
)## [1] "Cox model formula: Surv(time/12, event) ~ CMR_LGE_ischemic_presence"
# Save the plot in a folder
ggsave(
filename = here(figures_output_dir, paste0("Fig8-mid-KM-LGE_midwall_with_ischemic_plot-", Sys.Date(),".png")),
plot = results$ggsurv$plot, width = 10, height = 6, units = "in", dpi = 600)
ggsave(
filename = here(figures_output_dir,paste0("Fig8-mid-KM-LGE_midwall_with_ischemic_risk-", Sys.Date(),".png")),
plot = results$ggsurv$table, width = 10, height = 3, units = "in", dpi = 600)